Python + Java

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

    #1

    Python + Java

    Hi..

    How to connect Python with Java.
    This is my Python program. i use jpype to connect Python with Java.
    Code:
    from jpype import *
    startJVM("d:/Program Files/Java/jdk1.6.0/jre/bin/client/jvm.dll","-ea")
    jnavClass = JClass("Semantic")
    jnav = jnavClass()
    jnavClass.pilih_ayat("i go to school")
    shutdownJVM()
    and this is my Java program.
    Code:
    import java.text.BreakIterator; 
    class Semantic {
       // native C++ method
       //public native void printMessage( String message );
         public native String printMessage( String message );
       // load library JNIPrintMessage into JVM
       static {
          System.loadLibrary( "JNIPrintMessage" );
       }
    	  public static void main(String [] args) {  
    	   pilih_ayat();
    	  	}
    	  	  public static String pilih_ayat(String n){
    	        JNIPrintWrapper wrapper = new JNIPrintWrapper(); 
               	String ayat_siap = wrapper.printMessage(n);
    			System.out.println("output >>" + ayat_siap);
    			return n;
    		}//end pilih ayat
    	  public Semantic(){
    	  	System.out.println("Berjaya");
    	  }
    }//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?
Working...