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

Java»ù´¡ÖªÊ¶——JNIÈëÞ­µä

JNIÊÇJava Native InterfaceµÄËõд£¬Í¨¹ýʹÓÃnative·½·¨£¬Java¿ÉÒÔµ÷Óñ¾µØC/C++×Ó³ÌÐò¡£ÉùÃ÷Ò»¸ö±¾µØ×Ó³ÌÐòµÄ·½·¨ÊÇ£ºÔÚ·½·¨ÃûǰÌí¼ÓnativeÐÞÊΣ¬Èç
public native void myfun();
µ÷ÓøÃ×Ó³ÌÐòµÄ·½·¨Îª£º
static{
    System.loadLibrary("myfun");
}
ÔÚWindowsÉÏ£¬ÉÏÃæµÄmyfun¼´Ö¸°üº¬ÓÃC/C++дµÄmyfun()µÄʵÌåµÄDLL——myfun.dll¡£ÏÂÃæÒÔNativeDemo³ÌÐòΪÀýÀ´ËµÃ÷ÔõÑùÔÚWindowsÏ£¨XP+VS2008+JDK1.6u17£©Ê¹ÓÃJNI¡£
1. ±àдԴ³ÌÐòNativeDemo.java
NativeDemo.javaÖÐÉùÃ÷ÁËÒ»¸ö±¾µØ×Ó³ÌÐòtest()£º
public native void test();
¸Ã×Ó³ÌÐò´ÓÖ÷³ÌÐò»ñµÃint±äÁ¿iµÄÖµ£¬¶ÔÆä¼Ó±¶£¬È»ºó·µ»Ø¸øÖ÷³ÌÐò¡£¾ßÌå´úÂëÈçÏ£º
// Using Native method
public class NativeDemo{
    int i;
    public static void main(String args[]){
        NativeDemo ob=new NativeDemo();
        ob.i=10;
        System.out.println("This is ob.i before the native method: "+ob.i);
        ob.test(); //call a native method
        System.out.println("This is ob.i after the Native method: "+ob.i);
        ob.test(); //call a native method
       System.out.println("This is ob.i after the Native method: "+ob.i);
    }
    // declare native method
    public native void test();
    static{
         // load DLL that contains static method
         System.loadLibrary("NativeDemo");
    }
}
2. ±àÒëNativeDemo.java
javac NativeDemo.java
µÃµ½NativeDemo.class
3. ʹÓÃjavah.exeÉú³ÉNativeDemo.h
javah -jni NativeDemo
javah.exeÔÚ%JAVA_HOME%\binÏ£¬Éú³ÉµÄNativeDemo.hÈçÏ£º
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class NativeDemo */
#ifndef _I


Ïà¹ØÎĵµ£º

dz̸JavaµÄÊäÈëÊä³öÁ÷

 JavaÓïÑÔµÄÊäÈëÊä³ö¹¦ÄÜÊÇÊ®·ÖÇ¿´ó¶øÁé»îµÄ£¬ÃÀÖв»×ãµÄÊÇ¿´ÉÏÈ¥ÊäÈëÊä³öµÄ´úÂë²¢²»ÊǺܼò½à£¬ÒòΪÄãÍùÍùÐèÒª°ü×°Ðí¶à²»Í¬µÄ¶ÔÏó¡£ÔÚJavaÀà¿âÖУ¬IO²¿·ÖµÄÄÚÈÝÊǺÜÅÓ´óµÄ£¬ÒòΪËüÉæ¼°µÄÁìÓòºÜ¹ã·º:±ê×¼ÊäÈëÊä³ö£¬ÎļþµÄ²Ù×÷£¬ÍøÂçÉϵÄÊý¾ÝÁ÷£¬×Ö·û´®Á÷£¬¶ÔÏóÁ÷£¬zipÎļþÁ÷....±¾ÎĵÄÄ¿µÄÊÇΪ´ó¼Ò×öÒ»¸ö¼òÒªµÄ½éÉÜ¡£ ......

JavaÏß³ÌÖ® InterruptedException Òì³£

 µ±Ò»¸ö·½·¨ºóÃæÉùÃ÷¿ÉÄÜ»áÅ׳öInterruptedException Ò쳣ʱ£¬ËµÃ÷¸Ã·½·¨ÊÇ¿ÉÄܻỨһµãʱ¼ä£¬µ«ÊÇ¿ÉÒÔÈ¡ÏûµÄ·½·¨¡£
Å×InterruptedExceptionµÄ´ú±í·½·¨ÓУº
1. java.lang.Object ÀàµÄ wait ·½·¨
2. java.lang.Thread ÀàµÄ sleep ·½·¨
3. java.lang.Thread ÀàµÄ join ·½·¨
-- ÐèÒª»¨µãʱ¼äµÄ·½·¨
Ö´ÐÐwait·½·¨µÄÏ ......

JavaÊý¾Ý¿âÁ¬½Ó£¨JDBC£©·½Ê½ºÍ¼¼ÇÉ


 
JavaÊý¾Ý¿âÁ¬½Ó£¨JDBC£©ÓÉÒ»×éÓà Java ±à³ÌÓïÑÔ±àдµÄÀàºÍ½Ó¿Ú×é³É¡£JDBC Ϊ¹¤¾ß/Êý¾Ý¿â¿ª·¢ÈËÔ±ÌṩÁËÒ»¸ö±ê×¼µÄ API£¬Ê¹ËûÃÇÄܹ»Óô¿Java API À´±àдÊý¾Ý¿âÓ¦ÓóÌÐò¡£È»¶ø¸÷¸ö¿ª·¢É̵Ľӿڲ¢²»ÍêÈ«Ïàͬ£¬ËùÒÔ¿ª·¢»·¾³µÄ±ä»¯»á´øÀ´Ò»¶¨µÄÅäÖñ仯¡£±¾ÎÄÖ÷Òª¼¯ºÏÁ˲»Í¬Êý¾Ý¿âµÄÁ¬½Ó·½Ê½¡£
¡¡¡¡Ò»¡¢Á¬½Ó¸÷ÖÖÊý¾Ý¿ ......

³õѧJAVAÖ®Ò»

1¡¢ Ò»¸öÊýÈç¹ûÇ¡ºÃµÈÓÚÆäÒò×Ó£¨³ýÁ˱¾ÉíÒÔÍâµÄÔ¼ÊýÖ®ºÍ£©£¬¸ÃÊý¾Í³ÆÎª“ÍêÊý”¡£±àдһ¸ö Java Application  ³ÌÐò£¬Çó³ö 1000 ÒÔÄÚµÄËùÓÐÍêÊý¡£
 
public class homework11
{
public static void main(String[] args)
//Êä³ö1000ÒÔÄÚµÄËùÓÐÍêÊý
{
int sum;       ......

³õѧJAVAÖ®ËÄ

±àдһ¸ö¼òµ¥µÄÎı¾±à¼­Æ÷£¬ÒªÇ󣺾ßÓдò¿ª¡¢±£´æ¡¢Ð½¨£¬Õ³Ìù¡¢¸´ÖƵȹ¦ÄÜ£»¾ßÓÐÒ»¸ö¹¤¾ßÌõ¡£±àдһ¸öÀàËÆ Windows ¼Çʱ¾µÄ¼òµ¥³ÌÐò£¬¸Ã³ÌÐòÄܹ»´´½¨ÐÂÎļþ¡¢¶ÁÈ¡ÒѾ­´æÔÚµÄÎļþ¡¢²é¿´ºÍÐÞ¸ÄÎı¾ÒÔ¼°±£´æÎªÎı¾Îļþ¡£
ÔÝʱ»¹²»»á×ö£¬Å¬Á¦ÖС£¡£¡£¡£¡£¡£¡£¡£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ