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("Semantic")
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.BreakIterator;
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.loadLibrary( "JNIPrintMessage" );
9.
}
10.
public static void main(String [] args) {
11.
pilih_ayat();
12.
}
13.
public static String pilih_ayat(String n){
14.
JNIPrintWrapper wrapper = new JNIPrintWrapper();
15.
String ayat_siap = wrapper.printMessage(n);
16.
System.out.println("output >>" + ayat_siap);
17.
return n;
18.
}//end pilih ayat
19.
public Semantic(){
20.
System.out.println("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?