By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,957 Members | 1,960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,957 IT Pros & Developers. It's quick & easy.

how to connect python with java?

P: 14
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
Share this Question
Share on Google+
1 Reply


Subsciber123
P: 87
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.