Results 1 to 2 of 2
  1. #1
    hofsoc is offline Member
    Join Date
    Feb 2009
    Posts
    7
    Rep Power
    0

    Default Call java Methods from Python Script

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

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

Similar Threads

  1. [B] How to call Perl script from Java [/B]
    By JavaEmpires in forum Advanced Java
    Replies: 7
    Last Post: 12-19-2008, 04:10 PM
  2. Program To Call Random Methods
    By nyamtoko in forum Advanced Java
    Replies: 5
    Last Post: 12-01-2008, 12:49 PM
  3. How to call methods of different classes
    By adeeb in forum New To Java
    Replies: 2
    Last Post: 06-06-2008, 07:08 AM
  4. Replies: 0
    Last Post: 01-02-2008, 02:52 PM
  5. Calling Java methods form Python
    By mew in forum Advanced Java
    Replies: 1
    Last Post: 12-21-2007, 03:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •