javaµ÷ÓÃdllÀý×Ó
×î¼Ñ´ð°¸
1. ±àд·¶ÀýÎĵµ
public class TestNative
{
private native static int Max(int a,int b);
public static void main(String[] args)
{
System.out.println(Max(4,5));
}
static
{
System.loadLibrary("VCdll");
}
}
ÆäÖÐ
LoadLibraryÖеÄDLLÎļþÃû³Æ¿ÉÒÔËæ±ã¶¨.Ö»Òª×öºÃµÄ¶¯Ì¬Á´½Ó¿â¸ÄÃû³ÉÕâ¸ö×Ö·û´®¾Í¿ÉÒÔÁË.¶ønativeº¯ÊýµÄÀ´Ô´¾ÍÊǸö¯Ì¬Á´½Ó¿â.
2. ×öºÃ¸Ã²½×¼±¸ÒÔºó,ÓÃjavac TestNative.javaÉú³ÉTestNative.class. ¼ìÑéÓï·¨.
3. Óï·¨¼ì²éͨ¹ýÒÔºó,ÓÃjavah TestNativeÉú³ÉTestNative.hµÄC++Í·Îļþ.
4. ÓÃVC++6.0´´½¨dllÎļþ:
<1>msdev->new->project->win32 Dynamic-Link Library
<2>Enter project name (e.g. VCdll)
<3>choose "An empty DLL project"->finish
<4>½«3Éú³ÉµÄTestNative.hºÍjdkϵÄjni.hºÍjni_md.h¼ÓÈëµ½¹¤³ÌÖÐÈ¥
<5>Create a c++ file, implements the native method. as follows:
//TestNative.cpp
#include "TestNative.h"
JNIEXPORT jint JNICALL Java_TestNative_Max
(JNIEnv * a, jclass b, jint x, jint y)
{
return x > y ? x : y;
}
±¸×¢:
A ÆäÖеÄjni.hͨ³£ÔÚ jdk\include\ ¿ÉÒÔÏÈ¿½±´µ½VC°²×°Ä¿Â¼ÏµÄincludeĿ¼ÏÂ.Ò»ÀÍÓÀÒÝ,ÒÔºó¿ÉÒÔ·½±ãʹÓÃJNI¼¼Êõ.
B È«²¿µÄÊý¾ÝÀàÐÍÐèÒª¿¼ÂÇJavaºÍVCµÄ½Ó¿ÚÎÊÌâ.ÓÃjint jstring µÈ.
C º¯ÊýÃû³ÆºÍ×Ô¶¯Éú³ÉµÄ.hÎļþÖй涨µÄÒ»ÖÂ.ÃüÃû¹æÔòÊÇ: Java_ʹÓÃÀà_·½·¨Ãû
6. È«±àÒëÒ»ÏÂVC++¹¤³Ì.
Èç¹ûûÓгö´í,Ôò´ËʱÉú³É¶¯Ì¬Á´½Ó¿â³É¹¦.
°Ñ¶¯Ì¬Á´½Ó¿âVCdll.dll¿½±´µ½TestNative.javaËùÔÚµÄĿ¼ÉÏ.
7.ÔËÐÐjava TestNative. OK :-)
Ïà¹ØÎĵµ£º
´Ó×î³£¹æµÄ·Ö²ã½á¹¹À´Ëµ£¬ÏµÍ³²ã´Î´ÓÉϵ½ÏÂÒÀ´ÎΪ£º
±íÏֲ㣺Ö÷ÒªÊÇ¿Í»§¶ËµÄչʾ¡£
·þÎñ²ã£ºÖ±½ÓΪ¿Í»§¶ËÌṩµÄ·þÎñ»ò¹¦ÄÜ¡£Ò²ÊÇϵͳËùÄܶÔÍâÌṩµÄ¹¦ÄÜ¡£
ÁìÓò²ã£ºÏµÍ³ÄÚµÄÁìÓò»î¶¯¡£
DAO²ã£ºÊý¾Ý·ÃÎʶÔÏó£¬Í¨¹ýÁìÓòʵÌå¶ÔÏóÀ´²Ù×÷Êý¾Ý¿â¡£
ÆäÖÐÓÐЩָµ¼ÔÔò£º
& ......
javaÏ̳߳صÄÔÀíÓëʵÏÖ
[·ÖÏí]Java Ï̳߳صÄÔÀíÓëʵÏÖ2008-07-18
14:53------------------------------------------------------------------------------------------------
Õ⼸ÌìÖ÷ÒªÊÇ¿ñ¿´Ô´³ÌÐò£¬ÔÚÃÖ²¹ÁËһЩÒÔǰ֪ʶ¿Õ°×µÄͬʱ£¬Ò²Ñ§»áÁ˲»ÉÙеÄ֪ʶ£¨±ÈÈç NIO£©£¬»òÕß³ÆΪм¼Êõ°É ......
ÉùÃ÷£º
ÒÔϵÄÀý×Ó²»Ò»¶¨ÕýÈ·£¬Ö»ÊÇΪÁËÑÝʾ´ó¸ÅµÄÁ÷³Ì¡£
Ò»£ºÎÞ·µ»ØÖµµÄ´æ´¢¹ý³Ì
´æ´¢¹ý³ÌΪ£º
CREATE OR REPLACE PROCEDURE TESTA(PARA1 IN VARCHAR2,PARA2 IN VARCHAR2) AS
BEGIN
INSERT INTO HYQ.B_ID (I_ID,I_NAME) VALUES (PARA1, PARA2);
END TESTA;
È»ºóÄØ£¬ÔÚjavaÀïµ÷ÓÃʱ¾ÍÓÃÏÂÃæµÄ´ ......
<!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:ËÎÌå;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@SimSun&qu ......
µ½SunÍøÕ¾ÏÂÔØ×Ô½âѹ°²×°°üjdk-xxxx.bin
°²×°£º
[root@RHEL4 JDK-1.5.0.06]# chmod +x jdk-xxxx.bin
[root@RHEL4 JDK-1.5.0.06]# ./jdk-xxxx.bin
Ñ¡Ôñ°²×°Î»Öã¬
J2SDK°²×°Ä¿Â¼£º /usr/local/jdk
ÅäÖÃJava»·¾³±äÁ¿£º
ÔÚ ~/.bash_profile Àï¼ÓÈëÏÂÁм¸Ðл·¾³±äÁ¿¼´¿É£º
export JAVA_HOME=/usr/local/jdk
export PAT ......