JavaÖÐÈçºÎµ÷ÓÃVCµÄ¶¯Ì¬¿â
ÒÔǰһƪµÄDLLΪÀý²ûÊöJavaÈçºÎµ÷Óö¯Ì¬¿â
Ä¿Ç°´æÔÚÒ»¸öVC±àÒëµÄ·ÇMFC¶¯Ì¬¿âDLL£¨¾ßÌåÈçºÎÉú³É·ÇMFC¶¯Ì¬¿âDLL¼ûǰһƪÎÄÕ£©£¬Ãû³ÆΪmydll.dll£¬ÆäÖÐÓе¼³öº¯Êýmyadd£ºÐÎÈ磺int myadd(int,int)£¬ÏÖjavaÓ¦ÓóÌÐòÐèÒªµ÷Óøö¯Ì¬¿âµÄmyaddº¯Êý¡£¾ßÌåʵÏÖ²½ÖèÈçÏ£º
1¡¢±àдµ÷ÓÃmydll.dllµÄjava³ÌÐò
£¨1£©³ÌÐòtestMyDll .javaÈçÏ£º
public class testMyDll {
private native static int myadd(int a,int b);
static {
System.loadLibrary("javamydll"); //¸Ã¶¯Ì¬¿âÃû³ÆΪÖм䶯̬¿â£¬ÓÉjava³ÌÐòʹÓ㬸ºÔðµ÷ÓÃÐèҪʹÓõĶ¯Ì¬¿â¡£
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(myadd(4,5));
}
}
£¨2£©±àÒëtestMyDll .java³ÌÐò£¬¼ì²éÊÇ·ñ´æÔÚ´íÎó¡£
javac testMyDll .java
2¡¢Éú³ÉÍ·ÎļþtestMyDll.h£¬¹©Éú³ÉÖм䶯̬¿âʹÓá£
javah testMyDll
3¡¢Éú³ÉÖм䶯̬¿âjavamydll.dll
£¨1£©Ê¹ÓÃvc¹¤¾ßÏÈÉú³Éwin32 Dynamic-Link Library¿Õ¹¤³Ì
£¨2£©½«ÉÏÃæÉú³ÉµÄÍ·ÎļþtestMyDll.hÌí¼Ó½øÈ¥£¬Í¬Ê±»¹ÐèÒªÌí¼ÓjdkÏÂincludeĿ¼ÖÐ µÄjni.h¡¢jni_md.hÕâÁ½¸öÍ·Îļþ£¬×îºÃ½«jni.hÎļþ·ÅÈ밲װĿ¼ÏÂincludeµÄĿ¼ÏÂ
£¨3£©Ìí¼Óµ÷ÓÃÐèҪʹÓõĶ¯Ì¬¿âµÄʵÏÖÎļþtestMyDll.cpp
³ÌÐòÈçÏ£º
//testMyDll.cpp
#include <windows.h>
#include "testMyDll.h"
typedef int (*padd)(int,int);
JNIEXPORT jint JNICALL Java_testMyDll_myadd
(JNIEnv * a, jclass b, jint x, jint y)
{
HINSTANCE hins = ::LoadLibrary("mydll.dll");
if(hins == NULL)
{
return 0;
}
int res;
padd pa = (padd)GetProcAddress(hins,"myadd");
if(pa != NULL)
{
res = x+y;
}
::FreeLibrary(hins);
return res;
}
£¨4£©±àÒëÉú³ÉÖм䶯̬¿âjavamydll.dll
4¡¢½«Öм䶯̬¿âjavamydll.dllºÍÐèʹÓõĶ¯Ì¬¿âmydll.dll·ÅÔÚtestMyDll.classĿ¼Ï£¬ÔËÐиÃÀà: java testMyDll
³ÌÐòÊä³ö½á¹û£º9
´ÓÉÏÊöʵÏÖ·½·¨ÖпÉÒÔ¿´µ½£¬javaÐèÒªµ÷ÓÃÒÑÓеĶ¯Ì¬¿â£¬»¹ÐèÒª×Ô¼ºÉú³ÉÒ»¸öÖм䶯̬¿â£¬¸ºÔðµ÷ÓÃת»»¡£ËùÒÔЧÂʾͻáÓеãµÍ¡£
Ïà¹ØÎĵµ£º
public class Test4 {
public int binarySearch(int[] items, int value){
int startIndex = 0;
int stopIndex = items.length - 1;
int middle = (int)Math.flo ......
ÉϴηÖÎöÁËJava¶ÔprimitiveµÄÅÅÐò£¬Ê¹ÓõÄÊÇÓÅ»¯µÄ¿ìËÙÅÅÐòËã·¨¡£Õâ´Î½éÉÜJava¶ÔObject¶ÔÏó(Comparable)µÄÅÅÐò¡£
JavaʹÓÃÁ˹鲢¶ÔObjectÅÅÐò£¬¹ØÓڹ鲢ÅÅÐòµÄϸ½Ú£¬Çë²é¿´http://zh.wikipedia.org/zh/%E5%BD%92%E5%B9%B6%E6%8E%92%E5%BA%8F
¹é²¢ÅÅÐòÒ²ÓÐÒ»¸öÔËÐÐ״̬ͼ£¬²»¹ý¿´×Åȷʵͦ·Ñ½âµÄ =¡£=£¡
ÔÚÁ˽âÁ˹é ......
½ñÌìѧϰÁËapplet²¼¾ÖÎÊÌ⣺
°´Å¥¡¢±êÇ©ÊÇÔõÑù¼ÓÈëµ½applet³ÌÐò(ÈÝÆ÷)µ±ÖÐÈ¥µÄÄØ£¿
ÐèÒªÓõ½²¼¾ÖÈÝÆ÷¹ÜÀíÆ÷(LayoutManager)£ºËüÓÃÓÚÐÖúÈÝÆ÷È·¶¨¼ÓÈëµÄ×é¼þ(°´Å¥µÈ)Ó¦¸Ã·ÅÖõÄλÖÃ
awtÌṩÁË4Öг£ÓõIJ¼¾ÖÈÝÆ÷¹ÜÀíÆ÷
>>FlowLayout
>>BorderLayout
>>GridLayout
>>CardLayout
appletĬÈÏÊ ......
×î½ü×öspider£¬javaµÄÕýÔò±í´ïʽ½âÎö³öÿ¸öÍøÒ³µÄ³¬Á´½Ó£¬¸Ð¾õÕýÔòÕæµÄÉñͨ¹ã´ó£¡
´ó¸Å˵һÏ£¬ÎÒµÄͨ³£Ó÷¨¡£
ÕâÒ»²»Ö»ÊǽâÎö³ö <a href=""> Õⲿ·Ö
String regex = "(<a href=\")([\\S]+)(\")";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(sb); //sbÊÇÒ»¸öhtml ´ú ......
////////////////////////////////////////////////½ÚµãÀà TreeNode.java //////////////////////////
package com.tree;
class TreeNode {//°ü·ÃÎÊȨÏÞ
long data ;
long x,y;
String adrr;
Tre ......