Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎĵµ£º

javaÈëÃÅ

 Javaѧϰ´ÓÈëÃŵ½¾«Í¨ 
Ò»¡¢ JDK (Java Development Kit) 
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......

JavaÖÐnewºÍnewInstanceµÄÇø±ð

    ÔÚJavaÖУ¬Ê¹ÓÃnew¹Ø¼ü×ÖºÍClass.forName("a.class.Name").newInstance¶¼¿ÉÒÔ´´½¨¶ÔÏó£¬ËüÃÇÓÖÓÐʲôÇø±ðÄØ£¿
    1¡¢ÀàµÄ¼ÓÔØ·½Ê½²»Í¬¡£
    ÔÚÖ´ÐÐClass.forName("a.class.Name")ʱ£¬JVM»áÔÚclassapthÖÐÈ¥ÕÒ¶ÔÓ¦µÄÀಢ¼ÓÔØ£¬ÕâʱJVM»áÖ´ÐиÃÀàµÄ¾²Ì¬´úÂë¶Î¡£ÔÚʹÓà ......

³¬ÇáÁ¿¼¶JAVA¿ª·¢·½·¨(Ò»)

      Ä¿Ç°ÒÔEclipseΪÖ÷µÄÖØÁ¿¼¶¿ª·¢¹¤¾ß´óÐÐÆäµÀ.ËäÈ»¼«Îª·½±ã.µ«Èí¼þ°²×°¶ÔÓÚϵͳÅäÖò»¸ßµÄµçÄÔ»òÕßСÏîÄ¿¿ª·¢·Ç³£²»Àû.ÔÚÒÆÖ²¹ý³ÌÖл¹ÓÐÅäÖÃÎÊÌâ.±È½ÏÂé·³.Òò´Ë¶ÔÓÚһЩ³¬Ð¡ÏîÄ¿,ʹÓÃÇáÁ¿¼¶µÄ¿ª·¢·½·¨,ÏÔµÃÓÉΪ±ØÒª.Ëùν³¬ÇáÁ¿¼¶,¾ÍÊÇÓÃ×î¼òµ¥µÄ¹¤¾ßÍê³ÉJAVAϵͳµÄ¿ª·¢.ÔÚ¿ª·¢µ±ÖÐÒ²¿ÉÒÔÁ˽â ......

JVM ¶ÔJavaÒì³£µÄ´¦ÀíÔ­Àí

×î³õÎÒÃÇÓà Java д JSP µÄʱºò£¬¼¸ºõ¿ÉÒÔ²»´¥¼°Òì³££¬ÒòΪ Servlet ÈÝÆ÷»á°Ñ API Å׳öµÄÒì³£°ü×°³É
ServletException ¶ª¸øÈÝÆ÷È¥´¦Àí¡£ÔÙºóÀ´Ó¦Ó÷ֲ㣬´úÂëÖÐÒª´¦ÀíµÄÒì³£±ã¶àÁË£¬Ò»°ã»áת»»³É×Ô¶¨ÒåµÄÒµÎñÒì³£À࣬ÓÃ
try-catch-throw
customerException-finally¡£ÔÙµ½Èç½ñ¸÷ÖÖ¿ò¼ÜÈÕÕé³ÉÊ죬´úÂëÖÐÏÔʽµÄÒì³£´¦ÀíÓÖ½¥ ......

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


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