Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

jpythonµ÷ÓÃjavaÀàµÄÄ£°å


ʹÓÃJPypeÄ£¿éÈÃPythonµ÷ÓÃJAVAµÄÀà
Python idea!   2009-03-24 19:44   ÔĶÁ267   ÆÀÂÛ0  
×ֺţº ´ó´ó  ÖÐÖР СС
¿´¿´Àý×Ó¾ÍÖªµÀÀ²£¬ÕæÊÇΪPython£¨²»ÊÇJython£¬¶øÊÇCPython£©ÌṩÁËÇ¿´óÁ¦Á¿£¡
Ê×ÏÈÔÚjavaϽ¨Á¢Ò»¸öÔÙÒ²¼òµ¥²»¹ýµÄ°ü£º
package org.wg3i.test;
 
class Test {
    private String msg;
 
    public Test() {
    }
 
    public void speak(String msg) {
    System.out.println(msg);
    }
 
    public void setString(String s) {
    msg = s;
    }
 
    public String getString() {
    return msg;
    }
}
ÔÚPythonÏÂʹÓÃJPypeÄ£¿éÀ´µ÷ÓÃÎÒÃǸոÕÉú³ÉµÄjava°ü£º
import jpype
import os.path
 
jarpath = os.path.join(os.path.abspath('.'), 'build/jar')
jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.ext.dirs=%s" % jarpath)
Test = jpype.JClass('org.wg3i.test.Test')     # È¡µÃ°üorg.wg3i.testÖеÄÀàTest
t = Test()        # ´´½¨TestʵÀý
t.speak("This is a test message")      # ³¢ÊÔµ÷ÓÃÀàµÄÒ»¸ö·½·¨
t.setString("Hello, World")        #¸ø¶¨String
s = t.getString()        # »ñÈ¡String
print s
jpype.shutdownJVM()
ÏÂÃæÀ´½éÉÜÏÂÈçºÎµ÷Óðü¶ø²»ÊǾßÌåµÄÒ»¸öÀࣺ
import jpype
import os.path
 
classpath = os.path.join(os.path.abspath('.'), 'build/classes')
jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path=%s" % classpath)
testPkg = jpype.JPackage('org').wg3i.test         # È¡µÃ°ü
Test = testPkg.Test      # È¡µÃÀà
t = Test()     # ´´½¨TestʵÀý
t.speak("This is a test message")                 # ³¢ÊÔµ÷ÓÃÀàµÄÒ»¸ö·½·¨
t.setString("Hello, World")        &nbs


Ïà¹ØÎĵµ£º

JavaÖÐÈÃCPU±£³ÖÔÚÒ»ÌõÖ±ÏßÉÏ


 /**
  * @param args
  */
 public static void main(String[] args) {
  long time1 = System.currentTimeMillis();
  long time2 = System.currentTimeMillis();
  while (true) {
   while ((time1 - time2) < 30)
   & ......

JavaµÄһЩ»ã×Ü

1.//propertyÎļþµÄ¶ÁÈ¡
//com.test.messageÎļþ
package com.test;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Test_Messages {
private static final String BUNDLE_NAME = "com.test.messages";
private static final ResourceBundle RESOURCE_BUNDLE = Reso ......

JavaÖи²¸ÇÓëÖØÔصÄÇø±ð

     override¿ÉÒÔ·­ÒëΪ¸²¸Ç£¬´Ó×ÖÃæ¾Í¿ÉÒÔÖªµÀ£¬ËüÊǸ²¸ÇÁËÒ»¸ö·½·¨²¢ÇÒ¶ÔÆäÖØд£¬ÒÔÇó´ïµ½²»Í¬µÄ×÷Ó᣶ÔÎÒÃÇÀ´Ëµ×îÊìϤµÄ¸²¸Ç¾ÍÊǶԽӿڷ½·¨µÄʵÏÖ£¬ÔÚ½Ó¿ÚÖÐÒ»°ãÖ»ÊǶԷ½·¨½øÐÐÁËÉùÃ÷£¬¶øÎÒÃÇÔÚʵÏÖʱ£¬¾ÍÐèҪʵÏÖ½Ó¿ÚÉùÃ÷µÄËùÓз½·¨¡£³ýÁËÕâ¸öµäÐ͵ÄÓ÷¨ÒÔÍ⣬ÎÒÃÇÔڼ̳ÐÖÐÒ²¿ÉÄÜ»áÔÚ×ÓÀา¸Ç¸¸À ......

¡¾×ª¡¿ÓÅÐãJava³ÌÐòÔ±±ØÐëÁ˽âµÄGC¹¤×÷Ô­Àí

Ò»¸öÓÅÐãµÄJava³ÌÐòÔ±±ØÐëÁ˽âGCµÄ¹¤×÷Ô­Àí¡¢ÈçºÎÓÅ»¯GCµÄÐÔÄÜ¡¢ÈçºÎÓëGC½øÐÐÓÐÏ޵Ľ»»¥£¬ÒòΪÓÐһЩӦÓóÌÐò¶ÔÐÔÄÜÒªÇó½Ï¸ß£¬ÀýÈçǶÈëʽϵͳ¡¢ÊµÊ±ÏµÍ³µÈ£¬Ö»ÓÐÈ«ÃæÌáÉýÄÚ´æµÄ¹ÜÀíЧÂÊ £¬²ÅÄÜÌá¸ßÕû¸öÓ¦ÓóÌÐòµÄÐÔÄÜ¡£±¾ÆªÎÄÕÂÊ×Ïȼòµ¥½éÉÜGCµÄ¹¤×÷Ô­ÀíÖ®ºó£¬È»ºóÔÙ¶ÔGCµÄ¼¸¸ö¹Ø¼üÎÊÌâ½øÐÐÉîÈë̽ÌÖ£¬×îºóÌá³öһЩJava³ÌÐòÉ ......

JavaÖÐËÄÖÖXML½âÎö¼¼Êõ

DOMÊÇ»ùÓÚƽ̨¡¢ÓïÑÔÎ޹صĹٷ½W3C±ê×¼¡£»ùÓÚÊ÷µÄ²ã´Î£¬ÆäÓŵãÊÇ¿ÉÒÔÒÆÖ²£¬±à³ÌÈÝÒ×£¬¿ª·¢ÈËÔ±Ö»ÐèÒªµ÷Óý¨Ê÷µÄÖ¸Áî¡£ÆäȱµãÊǼÓÔØ´óÎļþ²»ÀíÏë¡£
¡¡¡¡SAXÊÇ»ùÓÚʼþÄ£Ð͵ģ¬ËüÔÚ½âÎö XML ÎĵµµÄʱºò¿ÉÒÔ´¥·¢Ò»ÏµÁеÄʼþ£¬µ±·¢ÏÖ¸ø¶¨µÄtagµÄʱºò£¬Ëü¿ÉÒÔ¼¤»îÒ»¸ö»Øµ÷·½·¨£¬¸æË߸÷½·¨Öƶ¨µÄ±êÇ©ÒѾ­ÕÒµ½¡£ÀàËÆÓëÁ÷ýÌåµÄ½ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ