Calling java from python
843785Feb 18 2009 — edited Feb 19 2009Hi,
I am trying to call java methods from a python script. Jython is not an option. I have looked at using Jpype. Below is my code thus far:
Jpype.py
from jpype import *
startJVM("C:\Program Files\Java\jdk1.6.0_12\jre\bin\client", "-ea", "-Djava.class.path=%s" % classpath)
com =JPackage("CallJavaFromPython")
jp = com.Jpype1()
jp.printArgument("XXX")
shutdownJVM()
================================================== =
Jpype1.class
package CallJavaFromPython;
public class Jpype1 {
public static void main(String args[]){
System.out.println(args[0]);
}
public void printArgument(String arg){
System.out.println(arg);
}
}
================================================== =
Error message i am getting when I try to run the python script is :
NameError: name 'startJVM' is not defined
has anyone come across this before?
Thanks in advance...