javaµ÷ÓÃC/C++дµÄdll
JavaÓïÑÔ±¾Éí¾ßÓпçƽ̨ÐÔ£¬Èç¹ûͨ¹ýJavaµ÷ÓÃDLLµÄ¼¼Êõ·½±ãÒ×Óã¬Ê¹ÓÃJava¿ª·¢Ç°Ì¨½çÃæ¿ÉÒÔ¸ü¿ìËÙ£¬Ò²ÄÜ´øÀ´¿çƽ̨ÐÔ¡£
Javaµ÷ÓÃC/C++дºÃµÄDLL¿âʱ£¬ÓÉÓÚ»ù±¾Êý¾ÝÀàÐͲ»Í¬¡¢Ê¹ÓÃ×Ö½ÚÐòÁпÉÄÜÓвîÒ죬ËùÒÔÔÚ²ÎÊý´«µÝ¹ý³ÌÖÐÈÝÒ׳öÏÖÎÊÌ⣬DLLÖпÉÄÜÐèÒª×öÏàÓ¦µÄת»»¡£
ʹÓÃJavaµ÷ÓÃDLL¶¯Ì¬Á´½Ó¿âµÄ·½°¸Í¨³£ÓÐÈýÖÖ£ºJNI, Jawin, Jacob. ÆäJNI(Java Native Interface)ÊÇJavaÓïÑÔ±¾ÉíÌṩµÄµ÷Óñ¾µØÒѱàÒëµÄº¯Êý¿âµÄ·½·¨£¬±¾Éí¾ßÓпçƽ̨ÐÔ£¬¿ÉÒÔÔÚ²»Í¬µÄ»úÆ÷Éϵ÷Óò»Í¬µÄ±¾µØ¿â¡£JawinºÍJacob¶¼ÊÇsourceforge.netµÄ¿ªÔ´ÏîÄ¿£¬¶¼ÊÇ»ùÓÚJNI¼¼ÊõµÄÒÀÀµWindowsµÄʵÏÖ£¬Ê¹µÃÔÚWindowsƽ̨ÏÂʹÓÃCOMºÍDLLµÄ¸ü¼Ó·½±ã¡£
ÏÂÃ棬ÎÒÃÇÀ´Ïêϸ½éÉÜÒ»ÏÂʹÓÃJNIÀ´ÊµÏÖJavaÓëC/C++Ö®¼äµÄµ÷Óá£
Ò»¡¢ JNI¼ò½é
JNIÊÇJava Native InterfaceµÄËõд¡£´ÓJava 1.1¿ªÊ¼£¬Java Native Interface(JNI)±ê×¼³ÉΪjavaƽ̨µÄÒ»²¿·Ö£¬ËüÔÊÐíJava´úÂëºÍÆäËûÓïÑÔдµÄ´úÂë½øÐн»»¥¡£JNIÒ»¿ªÊ¼ÊÇΪÁ˱¾µØÒѱàÒëÓïÑÔ£¬ÓÈÆäÊÇCºÍC++¶øÉè¼ÆµÄ£¬µ«ÊÇËü²¢²»·Á°ÄãʹÓÃÆäËûÓïÑÔ£¬Ö»Òªµ÷ÓÃÔ¼¶¨ÊÜÖ§³Ö¾Í¿ÉÒÔÁË¡£
sunÏà¹ØÎĵµ£ºhttp://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/jniTOC.html
¶þ¡¢ ¼òµ¥²½Öè
µÚÒ»²½£º
±àдJavaÀ࣬ÓøÃÀཫDLL¶ÔÍâÌṩµÄº¯Êý·þÎñ½øÐÐÉùÃ÷£¬ÆäÖеÄJava·½·¨¾ùÉùÃ÷Ϊnative£¬Æä·½·¨Ç©Ãû¿ÉÒÔ×Ô¶¨Ò壬²»ÓÃʵÏÖº¯ÊýÌå¡£Ò»¸öÀý×ÓÈçÏ£ºDllTest.java
public class DllTest
{
static
{
System.loadLibrary("chat");
}
public static native int connect(int i);
public static native String getstring(String src);
public static void main(String[] args)
{
DllTest dllTest = new DllTest();
System.out.println(dllTest.connect(5));
System.out.println(dllTest.getstring("java send"));
}
}
ÆäÖУ¬chatΪ¸Ã¶¯Ì¬¿âµÄÃû×Ö£¬ËüµÄÀ©Õ¹Ãû×Ö¿ÉÒÔ²»ÓÃд³öÀ´£¬¾¿¾
Ïà¹ØÎĵµ£º
1.Listת»»³ÉΪÊý×é¡££¨ÕâÀïµÄListÊÇʵÌåÊÇArrayList)
µ÷ÓÃArrayListµÄtoArray·½·¨¡£
Àý£ºString[] arr = (String[])list.toArray(new String[size]);
2.Êý×éת»»³ÉΪList¡£
µ÷ÓÃArraysµÄasList·½·¨¡£
Àý£ºList stooges = Arrays.asList("Larry", "Moe", "Curly"); ......
1.¼ÆËãijһÔ·ݵÄ×î´óÌìÊý
Calendar time=Calendar.getInstance();
time.clear();
time.set(Calendar.YEAR,year);
time.set(Calendar.MONTH,i-1);//×¢Òâ,Calendar¶ÔÏóĬÈÏÒ»ÔÂΪ0
int day=time.getActualMaximum(Calendar.DAY_OF_MONTH);//±¾Ô·ݵÄÌìÊý ......
Ç°Ò»ÕóÔÚ¹«Ë¾ÀïʹÓà jconsle ʱһÇÐÕý³££¬È»¶øÔÚ¼ÒÖеĻúÆ÷ÉÏÈ´³öÏÖÁ˱êÌâËùʾµÄÎÊÌ⣺
jconsole ºÍ jps ÎÞ·¨ÏÔʾ±¾µØ Java ½ø³ÌÁÐ±í¡£
µ±Ê±Ö±½ÓÀûÓà -Dcom.sun.management.jmxremote.port=port Æô¶¯Ä¿±ê java ½ø³Ì£¬²¢ÔÚ jconsole ÖÐͨ¹ý localhost:port ·½Ê½³É¹¦Á¬½ÓÉÏÄ¿±ê java ½ø³Ì¡£ÓÐÁËÕâ¸ö work around Ö®ºó£¬¶ÔÕ ......
Java±à³ÌÄÇЩʶù52—·½·¨ÉùÃ÷
µÚÆßÕÂ ·½·¨
·½·¨µÄÀ´Ô´
·½·¨µÄ¸ÅÄîÀ´Ô´ÓÚÊýѧÉϵĺ¯Êý£¬ÔÚÊýѧÖУ¬µ±Êý¾Ý¾ßÓÐÒ»¶¨µÄ¹æÂÉʱ£¬¾ÍÊÇÓÃÒ»¸öº¯ÊýÀ´´úÂë¸ÃÊý×ֵĹæÂÉ£¬ÀýÈçf£¨n£©=nÔò´ú±í1¡¢2¡¢3¡¢……ÕâÑùµÄÒ»¸öÊýÁС£ÔÚÊýѧÉÏnÊDzÎÊý£¬¶ÔÓÚÈ·¶¨µÄnÖµÖ»ÓÐÒ»¸öf£¨n£©µÄÖµºÍËü¶ÔÓ¦
·½·¨ÊÇÒ»×éΪÁËʵÏÖÌض¨¹¦Ä ......
¼òµ¥µÄ˵µ¥Àý¾ÍÊÇ Ö»ÄÜÓÐÒ»¸öʵÀý£¬ËùÒԵط½Óõ½µÄʵÀý¶¼ÊÇͬһ¸ö¡£
¾ÍºÃÏñ¼ÒÈ˳Է¹£¬×À×ÓÊǵ¥ÀýµÄ£¬´ó¼ÒÓõÄÊÇͬһ¸ö¡£¶øÍëÊǶàÀýµÄ£¬Ã¿È˶¼ÓÐ×Ô¼¸µÄ¡£ ÏÂÃæÊǾßÌåµÄÀý×Ó£º
Javaģʽ֮µ¥Àýģʽ£º
µ¥Àýģʽȷ±£Ò»¸öÀàÖ»ÓÐÒ»¸öʵÀý£¬×ÔÐÐÌṩÕâ¸öʵÀý²¢ÏòÕû¸öÏµÍ ......