468,272 Members | 2,020 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,272 developers. It's quick & easy.

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("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?
Mar 12 '08 #1
1 3923
You might find it worth looking into Jython, a Python interpreter written in Java.
Mar 21 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

114 posts views Thread by Maurice LING | last post: by
30 posts views Thread by Stuart Turner | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.