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Ϊ¸Ã¶¯Ì¬¿âµÄÃû×Ö£¬ËüµÄÀ©Õ¹Ãû×Ö¿ÉÒÔ²»ÓÃд³öÀ´£¬¾¿¾
Ïà¹ØÎĵµ£º
import java.awt.*;
import javax.swing.*;
import java.util.Date;
import java.awt.*;
class Time extends JFrame implements Runnable{//ʵÏÖ½Ó¿Ú
Thread clockThread;
JLabel jLabel=new JLabel();
public Time()
{
Container con=this.getContentPane() ......
JCP SE/EE Ö´ÐÐίԱ»á
Õýʽ½ÓÊÜÁË
JSR 330
—— Dependency Injection for Java¡£¸Ã¹æ·¶ÓÚ ½ñÄê 5 Ô 9 ÈÕ
ÓÉ Google µÄ Bob Lee ÒÔ¼° SpringSource µÄ Rod Johnson ×÷Ϊ¹æ·¶Áìµ¼Ìá½»¸ø JCP£¬ÏÖÔÚÒѾÕýʽ·¢²¼£¬²»µÃ²»¸Ð̾¸Ã¹æ·¶±ê×¼»¯¹ý³ÌÖ®¿ì¡£ÔÚ ×îÖÕͶƱ½á¹ûÖÐ
£¬14 Ʊͨ¹ý£¬1 ƱδͶ£¬1 Ʊ·´¶Ô¡£
J ......
¶ÔÓÚѧϰstaticÎÒÃÇÏÈÀ´¿´Á½¸öÀý×Ó£º
//Example 1 Tst.java£¬no main() method
package com.blogchina.qb2049;
public class Tst
{
static { System.out.println("111111"); }
}
ÔËÐнá¹ûΪ: 111111
Exception in thread "main" java.lang.NoSuchMethodError: main
ͬÑùµÄµÀÀí¿´µÚ¶þ ......
ÕâÊÇÒ»¸öÓÃJAVA W3C DOM ½øÐÐXML²Ù×÷µÄÀý×Ó£¬°üº¬Á˲éѯ¡¢Ôö¼Ó¡¢Ð޸ġ¢É¾³ý¡¢±£´æµÄ»ù±¾²Ù×÷¡£½ÏÍêÕûµÄÃèÊöÁËÒ»¸öXMLµÄÕû¸ö²Ù×÷Á÷³Ì¡£ÊʺϸÕÈëÃÅJAVA XML²Ù×÷µÄÅóÓѲο¼ºÍѧϰ¡£
¼ÙÉèÓÐXMLÎļþ£ºtest1.xml
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book>
< ......
Ç°Ò»ÕóÔÚ¹«Ë¾ÀïʹÓà jconsle ʱһÇÐÕý³££¬È»¶øÔÚ¼ÒÖеĻúÆ÷ÉÏÈ´³öÏÖÁ˱êÌâËùʾµÄÎÊÌ⣺
jconsole ºÍ jps ÎÞ·¨ÏÔʾ±¾µØ Java ½ø³ÌÁÐ±í¡£
µ±Ê±Ö±½ÓÀûÓà -Dcom.sun.management.jmxremote.port=port Æô¶¯Ä¿±ê java ½ø³Ì£¬²¢ÔÚ jconsole ÖÐͨ¹ý localhost:port ·½Ê½³É¹¦Á¬½ÓÉÏÄ¿±ê java ½ø³Ì¡£ÓÐÁËÕâ¸ö work around Ö®ºó£¬¶ÔÕ ......