JavaÖÐNative¹Ø¼ü×ÖµÄ×÷ÓÃ
Java²»ÊÇÍêÃÀµÄ£¬JavaµÄ²»×ã³ýÁËÌåÏÖÔÚÔËÐÐËÙ¶ÈÉÏÒª±È´«Í³µÄC++ÂýÐí¶àÖ®Í⣬JavaÎÞ·¨Ö±½Ó·ÃÎʵ½²Ù×÷ϵͳµ×²ã£¨ÈçϵͳӲ¼þµÈ)£¬Îª´ËJavaʹÓÃnative·½·¨À´À©Õ¹Java³ÌÐòµÄ¹¦ÄÜ¡£
¡¡¡¡¿ÉÒÔ½«native·½·¨±È×÷Java³ÌÐòͬ£Ã³ÌÐòµÄ½Ó¿Ú£¬ÆäʵÏÖ²½Ö裺
¡¡¡¡£±¡¢ÔÚJavaÖÐÉùÃ÷native()·½·¨£¬È»ºó±àÒ룻
¡¡¡¡£²¡¢ÓÃjavah²úÉúÒ»¸ö.hÎļþ£»
¡¡¡¡£³¡¢Ð´Ò»¸ö.cppÎļþʵÏÖnativeµ¼³ö·½·¨£¬ÆäÖÐÐèÒª°üº¬µÚ¶þ²½²úÉúµÄ.hÎļþ£¨×¢ÒâÆäÖÐÓÖ°üº¬ÁËJDK´øµÄjni.hÎļþ£©£»
¡¡¡¡£´¡¢½«µÚÈý²½µÄ.cppÎļþ±àÒë³É¶¯Ì¬Á´½Ó¿âÎļþ£»
¡¡¡¡£µ¡¢ÔÚJavaÖÐÓÃSystem.loadLibrary()·½·¨¼ÓÔصÚËIJ½²úÉúµÄ¶¯Ì¬Á´½Ó¿âÎļþ£¬Õâ¸önative()·½·¨¾Í¿ÉÒÔÔÚJavaÖб»·ÃÎÊÁË¡£
JAVA±¾µØ·½·¨ÊÊÓõÄÇé¿ö
1.ΪÁËʹÓõײãµÄÖ÷»úƽ̨µÄij¸öÌØÐÔ£¬¶øÕâ¸öÌØÐÔ²»ÄÜͨ¹ýJAVA API·ÃÎÊ
2.ΪÁË·ÃÎÊÒ»¸öÀϵÄϵͳ»òÕßʹÓÃÒ»¸öÒÑÓеĿ⣬¶øÕâ¸öϵͳ»òÕâ¸ö¿â²»ÊÇÓÃJAVA±àдµÄ
3.ΪÁ˼ӿì³ÌÐòµÄÐÔÄÜ£¬¶ø½«Ò»¶Îʱ¼äÃô¸ÐµÄ´úÂë×÷Ϊ±¾µØ·½·¨ÊµÏÖ¡£
Ê×ÏÈдºÃJAVAÎļþ
/*
* Created on 2005-12-19 Author shaoqi
*/
package com.hode.hodework.modelupdate;
public class CheckFile
{
public native void displayHelloWorld();
static
{
System.loadLibrary("test");
}
public static void main(String[] args) {
new CheckFile().displayHelloWorld();
}
}
È»ºó¸ù¾ÝдºÃµÄÎļþ±àÒë³ÉCLASSÎļþ
È»ºóÔÚclasses»òbinÖ®ÀàµÄclass¸ùĿ¼ÏÂÖ´ÐÐjavah -jni com.hode.hodework.modelupdate.CheckFile£¬
¾Í»áÔÚ¸ùĿ¼Ïµõ½Ò»¸öcom_hode_hodework_modelupdate_CheckFile.hµÄÎļþ
È»ºó¸ù¾ÝÍ·ÎļþµÄÄÚÈݱàдcom_hode_hodework_modelupdate_CheckFile.cÎļþ
££i nclude "CheckFile.h"
££i nclude
££i nclude
JNIEXPORT void JNICALL Java_com_hode_hodework_modelupdate_CheckFile_displayHelloWorld(JNIEnv *env, jobject obj)
{
printf("Hello world!\n");
return;
}
Ö®ºó±àÒëÉú³ÉDLLÎļþÈç“test.dll”£¬Ãû³ÆÓëSystem.l
Ïà¹ØÎĵµ£º
×÷ÕߣºÐûÕ×Åô
------------------------------------------------------------------------------------------------------------------------------------------
¹¤×÷µÚÒ»²½£ºÊìϤMyEclipseµÄ»·¾³ÒÔ¼°Ö÷Òª¹¦ÄÜ¡£
¹¤×÷µÚ¶þ²½£º½¨Á¢Êý¾Ý¿âÁ¬½Ó
Êý¾Ý¿â£ºMySQL
1¡¢MySQLµÄÅäÖÃÓëÎÊÌâ½â¾ö
Ïê¼ûÎ ......
²ÉÓô®¿Ú²Ù×÷½øÐжÌÐÅÊÕ·¢,ÊDZȽϳ£¼ûµÄÒ»ÖÖ·½Ê½.±ÈÈç,ºÜ¶àȺ·¢Èí¼þ,ÓõľÍÊÇÕâÖÖ·½·¨.
1.ÅäÖÃcomm.jar.
Comm.jarÊÇSubʵÏֵײ㴮¿Ú²Ù×÷µÄAPI,µ÷ÓÃÁ˱¾µØµÄDLLÎļþ,ÒòΪJava±¾Éí²»¾ß±¸Ö±½Ó·ÃÎÊÓ²¼þÉèÖõÄÄÜÁ¦,¶¼ÊÇͨ¹ýµ÷Óñ¾µØ·½·¨À´Êµ
ÏÖµÄ.¿ÉÒÔJavaµÄ¹Ù·½ÍøÕ¾ÏÂÔØ.ÏÂÔØÖ®ºó°ÑÆäÖÐComm.jar°üµ¼Èëµ½¹¤³ÌµÄClasspathÖÐ,°Ñ ......
ÏÖÔÚUrlRewriter¼¼ÊõÓÐÁ½¸ö¼¼Êõƽ̨µÄ£¬Ò»¸ö¾ÍÊÇÔÚJava·½ÏòµÄ£¬ÁíÒ»¸ö¾ÍÊÇ.NET·½ÏòµÄ¡£Õâ´ÎÊÇJava·½ÏòµÄÓ¦Óá£
Ê×ÏÈÈÃÎÒÃÇÁ˽âËüµÄ¹¤×÷ÔÀí£¬Ëµ°×ÁËËü¾ÍÊÇÒ»¸ö¼òµ¥µÄ¹ýÂËÆ÷£¨Filter£©£¬¿´¿´Ô´ÂëÄã¾Í»áºÜ¿ìµÄÃ÷°×£¬Ëü¾ÍÊÇͨ¹ýÎÒÃÇÔÚjspÖг£ÓõÄÁ½¸ö·½·¨ÊµÏÖµÄforward(),sendRedirect().
ÏÂÃæÎÒÃǾͿìËÙµÄΪÄãµÄÍøÕ¾´î½¨U ......
1¡¢Oracle8/8i/9iÊý¾Ý¿â£¨thinģʽ£©
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orclΪÊý¾Ý¿âµÄSID
String user="test";
String password="test";
Connection conn= DriverManager.getC ......
ÔÚÒ»¸öÏîÄ¿ÖУ¬¿Í»§ÓÃC#ʵÏÖÁËDES¼ÓÃÜ£¬ÓÉÓÚÐèÒªºÍjava·½ÃæµÄ³ÌÐò½øÐÐÊý¾Ý½»»¥£¬ËùÒÔ±ØÐëÅäºÏ½øÐмӽâÃܹ¤×÷¡£¿Í»§ÌṩÁËÃÜÔ¿ºÍÏòÁ¿£¬ÎÒ¿´ÁË¿´´úÂ룬c#×öÕâ¸öÊÂÇ黹Âù¼òµ¥¡£ ÓÃjavaʵÏֹؼüÊÇÎÒ²»×Ö¶ÎÔõôÉèÖÃÏòÁ¿£¬Ò»°ãÓÃCipher¶ÔÏó¶¼ÊÇĬÈÏËæ»úÏòÁ¿¡£¸ãÁËÒ»Õ󣬷¢ÏÖÊÇÓÃIvParameterSpecÕâ¸öÀàÀ´ÉèÖá£ÓÚÊÇÓÐÁËÒÔÏ´ú ......