NullPointerException while using struct.unpack() in Jython

91 Views Asked by At

I'm trying to use Jython in order to achieve struct.unpack() method of python. I've a String which is packed using python and I want to unpack it in java (using jython)

I've added the following dependency:

<dependency>
    <groupId>org.python</groupId>
    <artifactId>jython</artifactId>
    <version>2.5.0</version>
</dependency>

Following is the code through which I'm trying to achieve unpack.

struct.unpack("hhl", "\\x00\\x01\\x00\\x02\\x00\\x00\\x00\\x03");

I'm getting the following error:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.mli.PythonDemo.main(PythonDemo.java:79)
Caused by: java.lang.NullPointerException
    at org.python.core.Py.makeClass(Py.java:1548)
    at org.python.core.Py.makeClass(Py.java:1532)
    at org.python.modules.struct.<clinit>(struct.java:261)
    ... 1 more

Can someone tell me what am I doing wrong here. Is there anything else I'll have to to in order to use jython? Or I'm doing something wrong while calling the unpack().

0

There are 0 best solutions below