Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Calling java from python

843785Feb 18 2009 — edited Feb 19 2009
Hi,

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...

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 19 2009
Added on Feb 18 2009
6 comments
289 views