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

java native interface(JNI)¼¼Êõ¼òµ¥Ó¦ÓÃ

      ÊÖÉÏÒ»¸öÏîÄ¿ÐèҪͨ¹ýusb¿ÚÈ¥¶ÁÈ¡usbkeyµÄÐÅÏ¢£¬³§¼ÒÌṩµÄÖ»ÓÐC/C++µÄ½Ó¿Ú£¬¶øÖ÷Ó¦ÓÃÊÇjavaµÄ£¬ËùÒÔÐèҪʹÓÃjavaÈ¥µ÷Óö¯Ì¬Á´½Ó¿â£¬ËùÒÔ»¨Á˵ãʱ¼äÑо¿ÁËÏÂJNI¼¼Êõ£¬jdk¶ÔJNI¼¼Êõ·â×°µÃºÜµ½Î»£¬Ê¹ÓÃÆðÀ´·Ç³£¼òµ¥£¬JNI¼¼Êõ×î¹Ø¼ü»¹ÊÇÔÚÓÚjniÊý¾ÝÀàÐͺͱ¾µØÊý¾ÝÀàÐ͵Äת»»¡£Ïȼòµ¥ÂÞÁÐÏÂJNIµÄ´´½¨¹ý³Ì£º
      Ê×ÏÈÐèҪдһ¸öjavaÀ࣬Ȼºó¶¨ÒåÐèҪʹÓÃC/C++ȥʵÏֵķ½·¨£¨ËäȻ˵jniÊÇjava native interface£¬µ«ÊÇÄ¿Ç°Ö»Ö§³Öc/c++ʵÏÖ£©£¬Ê¹ÓÃnative¹Ø¼ü×ÖÉùÃ÷¡£ÕâÀïдһ¸ö¼òµ¥µÄÀý×Ó£º
TestJNI.java
package test.jni;
public class TestJNI
{

static
{
System.loadLibrary("TestJNI");
//Õâ¸öÊÇÖ®ºó²úÉúµÄ¿âµÄÃû×Ö£¬²»ÐèÒª¼Óºó׺£¬
//×Ô¶¯¸ù¾ÝϵͳÕÒ.dll»òÕß.so;
}
public native String helloWorld();

public static void main(String[] args)
{
TestJNI t = new TestJNI();
System.out.println(t.helloWorld());
}
}
È»ºó½«ÒÔÉÏÎļþʹÓÃjavac±àÒ룬ȻºóʹÓÃjavahÃüÁÈçÏ£º
javac test\jni\TestJNI.java
javah test.jni.TestJNI
Ö®ºó»áµÃµ½Ò»¸ötest_jni_TestJNI.hµÄÍ·Îļþ£¬ÄÚÈÝÈçÏ£º
test_jni_TestJNI.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class test_jni_TestJNI */
#ifndef _Included_test_jni_TestJNI
#define _Included_test_jni_TestJNI
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: test_jni_TestJNI
* Method: helloWorld
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_test_jni_TestJNI_helloWorld
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
È»ºó±àдc/c++ʵÏÖ£¬ÈçÏ£º
TestJNI.c
#include <stdio.h>
#include <jni.h>
#include <windows.h>
#include "test_jni_TestJNI.h"
JNIEXPORT jstring JNICALL Java_test_jni_TestJNI_helloWorld
(JNIEnv * env, jobject object){
//ÔÚcÖбØÐë¸øÐÎʽ²ÎÊýÉùÃ÷±äÁ¿Ãû£¬C++ÖпÉÒÔ²»Óã¬Í·ÎļþÖв»ÐèÒªÐ޸ģ»
const char* str = "helloWorld";
return (*env)->NewStringUTF(env,str);
//C++ÖпÉÒÔÖ±½Óenv->NewStringUTF(


Ïà¹ØÎĵµ£º

ʹÓÃJNI¼¼ÊõʵÏÖJAVA³ÌÐòµ÷ÓÃdll

JAVAµÄ¿çƽ̨µÄÌØÐÔÉîÊÜjava³ÌÐòÔ±ÃǵÄϲ°®,µ«ÕýÊÇÓÉÓÚËüΪÁËʵÏÖ¿çƽ̨µÄÄ¿µÄ,ʹµÃËüºÍ±¾µØ»úÆ÷µÄ¸÷ÖÖÄÚ²¿ÁªÏµ±äµÃºÜÉÙ,´ó´óÔ¼ÊøÁËËüµÄ¹¦ÄÜ,±ÈÈçÓëһЩӲ¼þÉ豸ͨÐÅ,ÍùÍùÒª»¨·ÑºÜ´óµÄ¾«Á¦È¥Éè¼ÆÁ÷³Ì±àд´úÂëÈ¥¹ÜÀíÉ豸¶Ë¿Ú,¶øÇÒÓÐһЩÉ豸³§ÉÌÌṩµÄÓ²¼þ½Ó¿ÚÒѾ­¾­¹ýÒ»¶¨µÄ·â×°ºÍ´¦Àí,²»ÄÜÖ±½ÓʹÓÃjava³ÌÐòͨ¹ý¶Ë¿ÚºÍÉè±¸Í ......

javaÖеÄstringÀàÐÍÈ«Ãæ½âÎö

1. Ê×ÏÈString²»ÊôÓÚ8ÖÖ»ù±¾Êý¾ÝÀàÐÍ£¬StringÊÇÒ»¸ö¶ÔÏó¡£
¡¡¡¡ÒòΪ¶ÔÏóµÄĬÈÏÖµÊÇnull£¬ËùÒÔStringµÄĬÈÏÖµÒ²ÊÇnull£»µ«ËüÓÖÊÇÒ»ÖÖÌØÊâµÄ¶ÔÏó£¬ÓÐÆäËü¶ÔÏóûÓеÄһЩÌØÐÔ¡£
¡¡¡¡2. new String()ºÍnew String(“”)¶¼ÊÇÉêÃ÷Ò»¸öеĿÕ×Ö·û´®£¬ÊÇ¿Õ´®²»ÊÇnull£»
¡¡¡¡3. String str=”kvill”£»
......

javaÖеÄclon()ºÍcloneable½Ó¿ÚdzÎö

 The clone( ) method generates a duplicate copy of the object on which it is called. Only classes that implement the Cloneable interface can be cloned.
 
...clone()²úÉúÁËÒ»¸öµ÷ÓÃËüµÄ¶ÔÏóµÄ¸´ÖÆ;Ö»ÓÐʵÏÖÁËCloneable½Ó¿ÚµÄÀà²Å¿ÉÒÔ±»¸´ÖÆ¡£
 
 
The Cloneable interface defines no ......

AESËã·¨javaʵÏÖdzÎö

      java jce¶ÔaesËã·¨ÓкܺõÄÖ§³Ö£¬µ«ÊÇĬÈÏ°²×°µÄJDK»òÕßJREÊDz»ÄÜÖ§³Öaes192bitÃÜÔ¿ºÍaes256bitÃÜÔ¿Á½ÖÖËã·¨µÄ£¬ÐèÒªµ½sun¹Ù·½ÏÂÔØJava(TM) Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files£¬ÒÔÏÂÊÇjce unilimited strength jurisdiction policy files 6µÄ¹Ù·½ ......

ѧϰJavaÖµ´«µÝ·½·¨

ѧϰJavaÖµ´«µÝ·½·¨-Î人±±´óÇàÄñ
¡¡¡¡Öµ´«µÝÊÇÔÚÒ»¸öº¯ÊýÖУ¬µ÷ÓÃÁíÍâÒ»¸öº¯Êý£¬ÆäÖк¬ÓвÎÊý´«µÝµÄÇé¿ö¡£ÍùÍùÖµ´«µÝ¾ÍÊÇ°ÑÊý¾Ý´«µÝµ½ÁíÍâÒ»¸öº¯ÊýÖнøÐнøÒ»²½´¦Àí£¬ÒÔ¸üÇå³þµØÏÔʾº¯ÊýµÄ±í´ïÒâ˼¡£ÔÚº¯Êýµ÷ÓõÄʱºò»áÓÐÊý¾Ý´«µÝ£¬Í¬ÑùÒª¿¼ÂÇÐβκÍʵ²ÎµÄÎÊÌ⣬ÈçÏÂÃæµÄÒ»¸ö³ÌÐò£º
¡¡¡¡on error resume next ShockMode ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ