how to connect python with java?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • datulaida
    New Member
    • May 2007
    • 14

    #1

    how to connect python with java?

    Hi..

    How to connect Python with Java.
    This is my Python program. i use jpype to connect Python with Java.
    Code: ( text )

    1.
    from jpype import *
    2.
    startJVM("d:/Program Files/Java/jdk1.6.0/jre/bin/client/jvm.dll","-ea")
    3.
    jnavClass = JClass("Semanti c")
    4.
    jnav = jnavClass()
    5.
    jnavClass.pilih _ayat("i go to school")
    6.
    shutdownJVM()



    and this is my Java program.
    Code: ( text )

    1.
    import java.text.Break Iterator;
    2.
    class Semantic {
    3.
    // native C++ method
    4.
    //public native void printMessage( String message );
    5.
    public native String printMessage( String message );
    6.
    // load library JNIPrintMessage into JVM
    7.
    static {
    8.
    System.loadLibr ary( "JNIPrintMessag e" );
    9.
    }
    10.
    public static void main(String [] args) {
    11.
    pilih_ayat();
    12.
    }
    13.
    public static String pilih_ayat(Stri ng n){
    14.
    JNIPrintWrapper wrapper = new JNIPrintWrapper ();
    15.
    String ayat_siap = wrapper.printMe ssage(n);
    16.
    System.out.prin tln("output >>" + ayat_siap);
    17.
    return n;
    18.
    }//end pilih ayat
    19.
    public Semantic(){
    20.
    System.out.prin tln("Berjaya");
    21.
    }
    22.
    }//end class



    How to move ("i go to school") at Python to pilih_ayat at Java. And then return ayat_siap to Python?
    Any idea?
  • Subsciber123
    New Member
    • Nov 2006
    • 87

    #2
    You might find it worth looking into Jython, a Python interpreter written in Java.

    Comment

    Working...