#75 Python crashes when trying to change a Java class variable.

Version 0.5
open
jpype-win32 (7)
5
2011-02-16
2011-02-16
Anonymous
No

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;
}
}

Discussion

  • Steve Menard

    Steve Menard - 2011-02-16

    Can you provide more details? IN aprticular the python code and the crash (stack trace, if any).

     
  • Nobody/Anonymous

    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()

     
  • Nobody/Anonymous

    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.

     
  • Steve Menard

    Steve Menard - 2011-02-16

    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()

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks