C/C++ÓÚJavaÖ®¼äµÄ»¥Ïàµ÷ÓÃ
ÀûÓÃJNI¼¼Êõ£¬¿ÉÒÔ×öµ½C/C++ÓëJavaÖ®¼äµÄÏ໥µ÷Óá£
1¡¢Javaµ÷ÓÃC/C++½Ó¿Ú
Õâ¸öÊÇJNI×î»ù±¾µÄÓ¦Óã¬JNIÓкܶàÕâ·½ÃæµÄÀý×Ó´úÂë¡£Ò»°ã°ÑC/C++д³É¶¯Ì¬Á´½Ó¿â£»ÔÚJava³ÌÐòÔÚLoadLibrary£¬ÀûÓÃnative½Ó¿Ú£¬¼´¿ÉÍê³Éµ÷Óá£
2¡¢C/C++»Øµ÷Java½Ó¿Ú
ÕâÖÖÓ÷¨£¬JNIµÄÀý×ӱȽÏÉÙ¡£Æäʵ£¬Ò²±È½Ï¼òµ¥£¬JNIÒ²ÌṩÁËÕâÑùµÄ½Ó¿Ú¡£±ÈÈ磬GetObjectClass£¬GetMethodID£¬CallObjectMethod£¬NewObject£¬FindClassµÈ½Ó¿Ú£¬¼´¿ÉÍê³ÉC/C++¶ÔJava½Ó¿ÚµÄµ÷Óá£
ÁíÍ⣬ÐèҪעÒâµÄÒ»¸öµØ·½ÊÇ£¬¹ØÓÚsignature¡£±ÈÈ磬ÔÚ jmethodID GetMethodID(jclass clazz, const char *name,
const char *sig) º¯ÊýÖеĵÚÈý¸ö²ÎÊý£¬¾ÍÐèÒªº¯ÊýµÄsignature¡£ÄÇÔõô֪µÀJava·½·¨µÄsignatureÄØ£¿
ÆäʵJDK£¬ÌṩÁ˲鿴Java·½·¨µÄsignature¡£·½·¨ÈçÏ£º
(1)¡¢CMD£¬È¥µ½xxx.classËùÔÚµÄĿ¼¡£
(2)¡¢ÊäÈëÃüÁjavap -s xxx
(3)¡¢½á¹û³ÊÏÖÔÚÄãÑÛÇ°¡£
ÑÓÉ죺Android NDKÒ²ÀàËÆ£¬Í¬Ñù¿ÉÒÔ×öµ½C/C++ÓëJavaÖ®¼äµÄ»¥µ÷¡£
Ïà¹ØÎĵµ£º
ÓÐʱ£¬ÎÒÃÇÔÚдһ¸ö¹¹Ô캯Êýʱ£¬¾³£ÒòΪËü°üº¬ÖÚ¶àµÄ²ÎÊý¶ø¿àÄÕ,Õâʱ¿ÉÒÔ¿¼ÂÇÓÃBuilderģʽÀ´´´½¨¶ÔÏó¡£
È磬ÎÒÃÇÒªÉè¼ÆÒ»¸öÓªÑø³É·ÝµÄÀ࣬°üº¬ÄÜÁ¿£¬µ°°×ÖÊ£¬Ö¬·¾£¬¸Æ£¬Ìú£¬Ð¿£¬Î¬ÉúËØA, άÉúËØB1 ... µÈ£¬µ«ÔÚ¹¹ÔìµÄʱºò£¬²»Ò»¶¨Ã¿´Î¶¼ÐèÒªÕâЩ²ÎÊý£¬Èç¸Æ£¬Ìú£¬Ð¿ºÍάÉúËصÈÊÇ¿ÉÑ¡µÄ£¬ÎªÁËÊÊÓ¦¶àÖÖ¿ÉÄܵĴîÅ䣬±È ......
package testPackage;
class Test {
public static void main(String[] args) {
String hello = "Hello", lo = "lo";
System.out.print((hello == "Hello") + " ");
System.out.print((Other.hello == hello) + " ");
System.out.print((other.Other.hello == hello) + " ");
System.out.print((hello == ("Hel"+"lo ......
1.Ê×ÏÈдһ¸öȨÏÞ¹ýÂËfilterÀà,ʵÏÖFilter½Ó¿Ú
/*Ê×ÏÈдһ¸öȨÏÞ¹ýÂËfilter*/
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.FilterChain;
import ......
¶ÔÓÚ½«ÒªÊ¹ÓõÄJSP¹æ·¶µÄÒ»¸öÌص㣬¾ÍÊÇJSP±í´ïʽÓïÑÔ¡£Ôںܴó³Ì¶ÈÉÏ£¬ËüÊÇÓÐÒâ¼ò»¯µÄ£¬²¢¶ÀÁ¢ÓÚJSP¡£
ÔÚJSPµÄÔçÆÚ°æ±¾ÖУ¬Java´úÂëÒԽű¾µÄÐÎʽǶÈëµ½JSPÒ³ÃæÖУ¬ÀýÈ磺
<%
MyBean bean = new MyBean();
String name = bean.getName();
out.println(name);
%>
Õâ¸ö½Å±¾´úÂëн¨ÁËÒ»¸öÃûΪMyBeanµÄʵÀý£¬»ñµÃË ......