Python crashes when trying to change a Java class variable.
Status: Beta
Brought to you by:
devilwolf
Python crashes when I try to change the class variable 'i' in Test
The class below is the culprit, I really don't get it why something this simple would cause Python to crash :s
Could anyone help me out here? Thanks in advance.
package py;
public class Test {
int i;
public void doTest() {
this.i = 5;
}
}
Can you provide more details? IN aprticular the python code and the crash (stack trace, if any).
Thanks for the quick response,
Well, the python process just terminates after calling Test.doTest(), wich is supposed to change the variable 'i' to 5 in Class Test.
The python code im trying to run is:
from jpype import *
JVM_DIR = "C:/Program Files/Java/jdk1.6.0_20/jre/bin/client/jvm.dll"
JVM = None
py = JPackage('py')
test = py.Test()
startJVM()
test.doTest()
def startJVM(self):
print "JVM started"
self.JVM = startJVM(self.JVM_DIR, "-Djava.class.path=./;./py/")
def closeJVM(self):
print "closing JVM"
self.JVM.shutdownJVM()
I believe I've discovered the problem. I didn't instantiate the python Test class, though I dont understand why it didnt print a stacktrace.
Thanks again,
Roy.
There is another problem. You can't lookup the class before you start the JVM
try this :
VM_DIR = "C:/Program Files/Java/jdk1.6.0_20/jre/bin/client/jvm.dll"
JVM = None
py = JPackage('py')
startJVM()
test = py.Test()
test().doTest()