JAVAµ÷DLL,.JNI¼¼Êõʵ¼ù
¼øÓÚÅÀ³æ¿ª·¢ÐèÒªÒ»¸öͼƬ½âÎö¹¦Äܵĺ¯Êý£¬µ½ÍøÂçÉϲéÕÒÁËһЩjni·½ÃæµÄÄÚÈÝ£¬²¢×öÁË×Ô¼ºµÄһЩÐ޸ģ¬¾ßÌåÈçÏ£º
Ä¿Ç°javaÓëdll½»»¥µÄ¼¼ÊõÖ÷ÒªÓÐ3ÖÖ£ºjni£¬jawinºÍjacob¡£Jni£¨Java Native Interface£©ÊÇsunÌṩµÄjavaÓëϵͳÖеÄÔÉú·½·¨½»»¥µÄ¼¼Êõ£¨ÔÚwindows\linuxϵͳÖУ¬ÊµÏÖjavaÓënative method»¥µ÷£©¡£Ä¿Ç°Ö»ÄÜÓÉc/c++ʵÏÖ¡£ºóÁ½¸ö¶¼ÊÇsourceforgeÉϵĿªÔ´ÏîÄ¿£¬Í¬Ê±Ò²¶¼ÊÇ»ùÓÚjni¼¼ÊõµÄwindowsϵͳÉϵÄÒ»¸öÓ¦Óÿ⡣Jacob£¨Java-Com Bridge£©ÌṩÁËjava³ÌÐòµ÷ÓÃmicrosoftµÄcom¶ÔÏóÖеķ½·¨µÄÄÜÁ¦¡£¶ø³ýÁËcom¶ÔÏóÍ⣬jawin£¨Java/Win32 integration project£©»¹¿ÉÒÔwin32-dll¶¯Ì¬Á´½Ó¿âÖеķ½·¨¡£¾Í¹¦ÄܶøÑÔ£ºjni >> jawin>jacob£¬Æä´óÖµĽṹÈçÏÂͼ£º
jni¼¼ÊõÌåϵ¹¦Äܽṹͼ
¾ÍÒ×ÓÃÐÔ¶øÑÔ£¬ÕýºÃÏà·´£ºjacob>jawin>>jni¡£
Jvm·â×°Á˸÷ÖÖ²Ù×÷ϵͳʵ¼ÊµÄ²îÒìÐÔµÄͬʱ£¬ÌṩÁËjni¼¼Êõ£¬Ê¹µÃ¿ª·¢Õß¿ÉÒÔͨ¹ýjava³ÌÐò£¨´úÂ룩µ÷Óõ½²Ù×÷ϵͳÏà¹ØµÄ¼¼ÊõʵÏֵĿ⺯Êý£¬´Ó¶øÓëÆäËû¼¼ÊõºÍϵͳ½»»¥£¬Ê¹ÓÃÆäËû¼¼ÊõʵÏÖµÄϵͳµÄ¹¦ÄÜ£»Í¬Ê±ÆäËû¼¼ÊõºÍϵͳҲ¿ÉÒÔͨ¹ýjniÌṩµÄÏàÓ¦ÔÉú½Ó¿Ú¿ªµ÷ÓÃjavaÓ¦ÓÃϵͳÄÚ²¿ÊµÏֵŦÄÜ¡£
ÔÚwindowsϵͳÉÏ£¬Ò»°ã¿ÉÖ´ÐеÄÓ¦ÓóÌÐò¶¼ÊÇ»ùÓÚnativeµÄPE½á¹¹£¬windowsÉϵÄjvmÒ²ÊÇ»ùÓÚnative½á¹¹ÊµÏֵġ£JavaÓ¦ÓÃÌåϵ¶¼Êǹ¹½¨ÓÚjvmÖ®ÉÏ¡£
WindowsϵͳÉϵÄjavaÌåϵ
Jni¶ÔÓÚÓ¦Óñ¾ÉíÀ´Ëµ£¬¿ÉÒÔ¿´×öÒ»¸ö´úÀíģʽ¡£¶ÔÓÚ¿ª·¢ÕßÀ´Ëµ£¬ÐèҪʹÓÃc/c++À´ÊµÏÖÒ»¸ö´úÀí³ÌÐò£¨jni³ÌÐò£©À´Êµ¼Ê²Ù×÷Ä¿±êÔÉúº¯Êý£¬java³ÌÐòÖÐÔòÊÇjvmͨ¹ý¼ÓÔز¢µ÷ÓôËjni³ÌÐòÀ´¼ä½ÓµØµ÷ÓÃÄ¿±êÔÉúº¯Êý¡£
Jniµ÷Óùý³ÌʾÒâͼ
l Jni³ÌÐò¿ª·¢µÄÒ»°ã²Ù×÷²½ÖèÈçÏ£º
1. ±àдjavaÖеĵ÷ÓÃÀ࣬²¢ÓÃjavac °üÃû.*.java ÃüÁî µÃµ½¸Ãµ÷ÓÃÀàµÄclassÎļþ
2. ÓÃjavah °üÃû.* Éú³Éc/c++ÔÉúº¯ÊýµÄÍ·Îļþ
3. c/c++Öе÷ÓÃÐèÒªµÄÆäËûº¯Êý¹¦ÄÜ£¬ÊµÏÖÔÉúº¯Êý(ÔÔòÉÏ¿ÉÒÔµ÷ÓÃÈκÎ×ÊÔ´)
4. ½«ÏîÄ¿ÒÀÀµµÄËùÓÐÔÉú¿âºÍ×ÊÔ´¼ÓÈëµ½javaÏîÄ¿µÄjava.library.path
5. Éú³Éjavaµ÷ÓÃÀà¶ÔÓ¦µÄdll¿â
6. ·¢²¼javaÓ¦ÓúÍdll¿â
l
Ïà¹ØÎĵµ£º
ÏÈ¿´Ò»¶Î´úÂë
public class Hello{
public static void main(String[] args){
int i = 5 , j = 2;
System.out.println(i+j);
......
Á½¸ötomcat Java¶¨Ê±ÈÎÎñµÄÀý×Ó
ÀýÒ»£º
±¾ÀýÒÀ¾ÝJava×ÔÉíÌṩµÄ½Ó¿ÚʵÏÖ£¬Í¨¹ý¼àÌýÆ÷£¨Listener£©ºÍ¶¨Ê±Æ÷£¨Timer£©¶¨Ê±Ö´ÐÐij¸öÈÎÎñ£¨Task£©¡£
רҵµÄ¿ªÔ´¹¤¾ß¿É²Î¿¼Quartz£ºhttp://www.opensymphony.com/quartz/
MyListener£º
import
java.util.Timer;
import
javax.servlet.ServletContextEvent;
i ......
javaÏ̳߳صÄÔÀíÓëʵÏÖ
[·ÖÏí]Java Ï̳߳صÄÔÀíÓëʵÏÖ2008-07-18
14:53------------------------------------------------------------------------------------------------
Õ⼸ÌìÖ÷ÒªÊÇ¿ñ¿´Ô´³ÌÐò£¬ÔÚÃÖ²¹ÁËһЩÒÔǰ֪ʶ¿Õ°×µÄͬʱ£¬Ò²Ñ§»áÁ˲»ÉÙеÄ֪ʶ£¨±ÈÈç NIO£©£¬»òÕß³ÆΪм¼Êõ°É ......
ÓÐÁ½ÖÖ·½·¨£º
·½·¨Ò»£ºÓÃjava.util.DateÀàÀ´ÊµÏÖ£¬²¢½áºÏjava.text.DateFormatÀàÀ´ÊµÏÖʱ¼äµÄ¸ñʽ»¯£¬¿´ÏÂÃæ´úÂ룺
import java.util.*;
import java.text.*;
//ÒÔÏÂĬÈÏʱ¼äÈÕÆÚÏÔʾ·½Ê½¶¼ÊǺºÓïÓïÑÔ·½Ê½
//Ò»°ãÓïÑÔ¾ÍĬÈϺºÓï¾Í¿ÉÒÔÁË£¬Ê±¼äÈÕÆڵĸñʽĬÈÏΪMEDIUM·ç¸ñ£¬±ÈÈ磺2008-6-16 20:54:53
//ÒÔÏÂÏÔʾµÄÈ ......
JAVAµÄ¿çƽ̨µÄÌØÐÔÉîÊÜjava³ÌÐòÔ±ÃǵÄϲ°®,µ«ÕýÊÇÓÉÓÚËüΪÁËʵÏÖ¿çƽ̨µÄÄ¿µÄ,ʹµÃËüºÍ±¾µØ»úÆ÷µÄ¸÷ÖÖÄÚ²¿ÁªÏµ±äµÃºÜÉÙ,´ó´óÔ¼ÊøÁËËüµÄ¹¦ÄÜ,±ÈÈçÓëһЩӲ¼þÉ豸ͨÐÅ,ÍùÍùÒª»¨·ÑºÜ´óµÄ¾«Á¦È¥Éè¼ÆÁ÷³Ì±àд´úÂëÈ¥¹ÜÀíÉ豸¶Ë¿Ú,¶øÇÒÓÐһЩÉ豸³§ÉÌÌṩµÄÓ²¼þ½Ó¿ÚÒѾ¾¹ýÒ»¶¨µÄ·â×°ºÍ´¦Àí,²»ÄÜÖ±½ÓʹÓÃjava³ÌÐòͨ¹ý¶Ë¿ÚºÍÉè±¸Í ......