ÔÚJavaÖе÷ÓÃC++
ÔÚjavaÖе÷ÓÃ×Ô¼ºµÄc++´úÂëÊÇÒ»¼þ¼òµ¥µÄÊÂÇ飬ÒÔÏÂÀàΪÀý£º
class Prompt {
private native String getLine(String prompt);
public static void main(String args[]) {
Prompt p = new Prompt();
String input = p.getLine("Type a line: ");
System.out.println("User typed: " + input);
}
static {
System.loadLibrary("MyImpOfPrompt");
}
}
ÎÒÃÇÏ£ÍûÔÚPromptÀàÖпÉÒÔµ÷ÓÃc++ϵÄgetLineº¯Êý£¬µÚÒ»²½¾ÍÊÇÏȱàÒë¸ÃjavaÎļþ£º
javac Prompt.java
´ËʱӦ¸ÃÒѾÉú³ÉÁËPrompt.classÎļþ£¬È»ºóʹÓÃÃüÁ
javah -jni Prompt
¼´¿ÉÉú³ÉÏàÓ¦µÄ.hÎļþ£¬ÆäÄÚÈÝΪ£º
JNIEXPORT jstring JNICALL
Java_Prompt_getLine(JNIEnv *, jobject, jstring);
ÊÂʵÉÏJavaµ÷ÓÃc++Ö»ÐèÒªÂú×ãÒ»¸ö½Ó¿ÚÃüÃû¹æ·¶¼´¿É£¬¶øjavah -jniÃüÁîÔòΪ¿ìËÙÉú³É½Ó¿ÚÌṩÁË·½±ã¡£
×îºó£¬¼ÇµÃ½«ÄãµÄc++´úÂë±àÒëΪlibMyImpOfPrompt.so
¸üÏêϸµÄ¹æ·¶¼°²Ù×÷¿ÉÒԲμû
http://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/index.html
Ïà¹ØÎĵµ£º
import java.io.*;
public class FileReaderSample {
public static void main(String args[]) throws IOException
{
// ½¨Á¢¿ÉÈÝÄÉ1024¸ö×Ö·ûµÄÊý×é
char data[]=new char[1024];
// ½¨Á¢¶ÔÏófr
FileReader fr= ......
import java.io.*;
import java.lang.String;
public class Switchover {
public static String[] strChi = {"Áã","Ò¼","·¡","Èþ","ËÁ","Îé","½","Æâ","°Æ","¾Á"};
public static String[] strUnits = {"","","ʰ","°Û","Ǫ","Íò","ʰ","°Û","Ǫ","ÒÚ","ʰ","°Û","Ǫ","Õ×","ʰ","°Û","Ǫ","½Ç","·Ö"};
//ÑéÖ¤Êä ......
JDO ¸ÅÊö
¡¡¡¡³¤¾ÃÒÔÀ´£¬Java Ó¦ÓóÌÐòºÍ³Ö¾ÃÊý¾Ý¹ÜÀíÖ®¼äµÄ¹ØÏµÒ»Ö±ÊDz»ÈÝÒ×´¦ÀíµÄ¡£Ðí¶à³Ö¾ÃÐÔ»úÖÆÒÔ¹ØÏµµÄ·½·¨¶ø²»ÊÇÃæÏò¶ÔÏó·½·¨´æ´¢Êý¾Ý¡£¼´£¬Êý¾Ý´æ´¢ÔÚÓɰüº¬×ֶεļǼ×é³ÉµÄ±íÖУ¬¶ø²»ÊǴ洢Ϊ×Ô°üº¬¶ÔÏó(ÕâЩ¶ÔÏóÓµÓÐÄÚ²¿Êý¾ÝºÍ¶ÔÆäËü¶ÔÏóµÄÒýÓ㬶øÆäËü¶ÔÏóÒ²ÓµÓÐÄÚ²¿Êý¾ÝºÍÒýÓÃ)¡£½«ÃæÏò¶ÔÏóµÄ±íʾת»»³ ......
¸ö ÈË ¼ò Àú
ÐÕ Ãû£º
ÍõÖ¾¹ú
ÐÔ ±ð£º
ÄÐ
Äê Á䣺
23Ëê
ÁªÏµµç»°£º
13124799190
ר Òµ£º
¼ÆËã»ú¼¼Êõ
¹¤×÷ʱ¼ä£º
Ò»ÄêÒÔÉÏ
ѧ Àú£º
´óר
ÓÊ Ï䣺
andy478168@yeah.net
¡ï ÇóÖ°ÒâÏò
¹¤×÷ÐÔÖÊ ......