Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ͨ¹ý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&


Ïà¹ØÎĵµ£º

javaÖеĹ¹Ôì·½·¨

1.¹¹Ôì·½·¨£ºÊÇÖ¸·½·¨ÃûÓëÀàÃûÏàͬµÄ·½·¨£¬°üÀ¨“×Ô¶¨Òå¹¹Ôì·½·¨”ºÍ“ĬÈϵĹ¹Ôì·½·¨”
                  ÔÚ´´½¨¶ÔÏóʱ  Èç¹ûÀàÖÐÒѾ­×Ô¶¨ÒåÁ˹¹Ôì·½·¨  ÄÇô±ØÐëʹÓøù¹Ôì·½·¨À´¹¹Ôì¶ÔÏó£»Èç¹ûÀ ......

javaÖеĶÔÏó¸³ÖµÎÊÌâ

ÔÚjavaÖР ¿ÉÒÔ½«Ä³¸ö¶ÔÏó¸³Öµ¸øÁíÒ»¸ö¶ÔÏó  Ö»Òª¸ÃÁ½¸ö¶ÔÏóÊÇÊôÓÚͬһ¸öÀ༴¿É  ´Ëʱ  ÕâÁ½¸ö¶ÔÏóµÄËùÓгÉÔ±½«Ö¸Ïòͬһ¿éÄÚ´æ
eg£º
      public class class1
         {
        &n ......

java»·¾³±äÁ¿ÅäÖÃ

£¨1£©Ctrl+M £­£­Çл»´°¿ÚµÄ´óС
£¨2£©Ctrl+Q £­£­Ìøµ½×îºóÒ»´ÎµÄ±à¼­´¦
£¨3£©F2        £­£­µ±Êó±ê·ÅÔÚÒ»¸ö±ê¼Ç´¦³öÏÖTooltipʱºò°´F2Ôò°ÑÊó±êÒÆ¿ªÊ±Tooltip»¹»áÏÔʾ¼´Show Tooltip Description¡£
          F3   ......

JAVA½ØÆÁ³ÌÐò(µÚËİæ)

×òÌì¿´µ½ÁôÑÔ,ÓÚÊǽñÌìÓÖ°ÑһЩ¹¦Äܼӽø½øÈ¥ÁË
±ÈÈç,
1,³ÌÐò¿ÉÒÔ×îС»¯µ½ÏµÍ³ÍÐÅÌÇø
2,³ÌÐò¿ÉÒÔÅúÁ¿±£´æËùÓнعýµÄͼƬ
3,ÐÞÕýÁËÒÔǰµÄÒ»¸öСBUG,ÄǾÍÊÇÊäÈë±£´æÍ¼Æ¬µÄÎļþÃûʱ,Èç¹ûûÓÐÊäÈëºó׺Ãû,½«±£´æÕý³£,Èç¹ûÊäÈëÁ˺ó׺Ãû,½«»á±£´æ¸ñʽ³ö´í
´ò°üÎļþÇëµã»÷ÕâÀïÏÂÔØ,distÎļþ¼ÐÀïÃæµÄJARÎļþÊÇ¿ÉÒÔË«»÷Ö´ÐеÄ
¸Ð ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ