ͨ¹ýJNI ʵÏÖ javaÓëC++Ö®¼äµÄÐÅÏ¢´«µÝ
¶¨ÒåÒ»¸önative ·½·¨£º
package ext;
import java.util.Hashtable;
public class TestJNI
{
static
{
System.loadLibrary("dllfile");
}
public TestJNI()
{
Hashtable htable = new Hashtable();
htable.put(1,2);
}
public native Hashtable getNameList();
public static void main(String[] arg)
{
TestJNI tstJNI= new TestJNI();
Hashtable htable= tstJNI.getNameList();
System.out.println(htable.size());
}
}
ͨ¹ý javah Éú³É Í·Îļþ ext_TestJNI.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include "jni.h"
/* Header for class ext_TestJNI */
#ifndef _Included_ext_TestJNI
#define _Included_ext_TestJNI
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: ext_TestJNI
* Method: getNameList
* Signature: ()Ljava/util/Hashtable;
*/
JNIEXPORT jobject JNICALL Java_ext_TestJNI_getNameList
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
ÔÚc++´´½¨Ò»¸ödynamic dllÏîÄ¿£¬²¢ÔÚ StdAfx.h ÖÐ include Í·Îļþ ext_TestJNI.h
StdAfx.h ´úÂ룺
#if !defined(AFX_STDAFX_H__FAD3F2E4_D6E1_4011_9791_2256C4B0BDE6__INCLUDED_)
#define AFX_STDAFX_H__FAD3F2E4_D6E1_4011_9791_2256C4B0BDE6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Insert your headers here
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include "ext_TestJNI.h"
ÔÚ CPPÎļþÖж¨Òå ·½·¨ÊµÏÖ£º
CPP´úÂ룺
#include "stdAfx.h&
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
×÷Õߣºrobbin
꿅᣼http://www.fankai.com/
Java Learning Path £¨Ò»£©¡¢¹¤¾ßƪ
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕ ......
Ò»¡¢Java»ù´¡ÖªÊ¶
1.JavaÓÐÄÇЩ»ù±¾Êý¾ÝÀàÐÍ£¬StringÊDz»ÊÇ»ù±¾Êý¾ÝÀàÐÍ£¬ËûÃÇÓкÎÇø±ð¡£
2.×Ö·û´®µÄ²Ù×÷£º
дһ¸ö·½·¨£¬ÊµÏÖ×Ö·û´®µÄ·´×ª£¬È磺ÊäÈëabc£¬Êä³öcba
дһ¸ö·½·¨£¬ÊµÏÖ×Ö·û´®µÄÌæ»»£¬È磺ÊäÈëbbbwlirbbb£¬Êä³öbbbhhtccc¡£
3.Êý¾ÝÀàÐÍÖ®¼äµÄת»»
ÈçºÎ½«ÊýÖµÐÍ×Ö·ûת»»ÎªÊý×Ö£¨Intege ......
ÔÚjavaÖÐ ¿ÉÒÔ½«Ä³¸ö¶ÔÏó¸³Öµ¸øÁíÒ»¸ö¶ÔÏó Ö»Òª¸ÃÁ½¸ö¶ÔÏóÊÇÊôÓÚͬһ¸öÀ༴¿É ´Ëʱ ÕâÁ½¸ö¶ÔÏóµÄËùÓгÉÔ±½«Ö¸Ïòͬһ¿éÄÚ´æ
eg£º
public class class1
{
&n ......