¶¨ÖÆjavaÐéÄâ»ú
×î½üÓÐÍøÓÑÎÊ£ºÈçºÎÈÃÒ»¸öJARÎļþËæJVMÆô¶¯Ê±ÔËÐУ¿java.exeÊDz»Äܹ»×ö³ÉÕâÑùµÄ£¬²»¹ý¿ÉÒÔ×Ô¼º¶¨ÖÆjava.exe£¬¶¨ÖÆjava.exeÔÚÈçÏÂÇé¿öÓÐÓãº
1.²»Ïë³ÌÐòµÄ½ø³ÌÃûÏÔʾΪjava.exe
2.Ï£Íû³ÌÐòË«»÷¾Í¿ÉÒÔÔËÐС£
ÏÂÃæÊÇÒ»¶ÎʾÀý´úÂ룺
// JVM_CPP.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "windows.h"
#include <jni.h>
typedef jint (JNICALL *JNICREATEPROC)(JavaVM**, void**, void*);
bool setStream(JNIEnv* env, const char* pszFileName, const char* pszMethod);
//Æô¶¯javaÐéÄâ»ú·½·¨
bool startJvm()
{
//jvm¶¯Ì¬¿âµÄ·¾¶
const TCHAR szJvmPath[] = _T("E:\\java\\jdk\\jdk1.6.0\\jre\\bin\\server\\jvm.dll");
//java ÐéÄâ»úµÄÆô¶¯²ÎÊý£¬Ã¿¸ö²ÎÊýдһÏ²»ÄܺÏÔÚÒ»Æðд
int nOptionCount = 2;
JavaVMOption options[2];
options[1].optionString = "-Xmx256M";
//ÉèÖÃclasspath
options[0].optionString = "-Djava.class.path=./Test.jar;";
JavaVMInitArgs vm_args;
vm_args.version = JNI_VERSION_1_4;
vm_args.options = options;
vm_args.nOptions = nOptionCount;
vm_args.ignoreUnrecognized = JNI_TRUE;
//Æô¶¯Àà,×¢Òâ·Ö¸î·ûÊÇ/£¬ÀýÈçÆô¶¯Ààtest.JTestÓ¦¸Ãд³É test/JTest
const char szStartClass[] = "com/kortide/JVM/Test";
//Æô¶¯·½·¨£¬Í¨³£ÊÇmainº¯Êý£¬ÄãÒ²¿ÉÒÔÉ趨³ÉÆäËûº¯Êý
const char szStartMethod[] = "main";
//Öص¼ÏòÎļþ
const char* szStdoutFileName = "stdout.txt";
const char* szStderrFileName = "stderr.txt";
//java³ÌÐòµÄÃüÁîÐвÎÊý
int nParamCount = 2;
const char* szParams[2] =
{
"arg1", "arg2"
};
//¼ÓÔØJVM¡£
HINSTANCE jvmDll = LoadLibrary(szJvmPath);
if (jvmDll == NULL)
{
printf("¼ÓÔØJVM¶¯Ì¬¿â´íÎó¡£%l", ::GetLastError());
return false;
}
//²éÕÒJNI_CreateJavaVM¹ý³Ì¡£
JNICREATEPROC jvmCreateProc = (JNICREATEPROC) GetProcAddress(jvmDll,
"JNI_CreateJavaVM");
if (jvmCreateProc == NULL)
{
FreeLibrary(jvmDll);
prin
Ïà¹ØÎĵµ£º
¹Ø¼ü×Ö: json java
JSON-libÕâ¸öJavaÀà°üÓÃÓÚ°Ñbean,mapºÍXMLת»»³ÉJSON²¢Äܹ»°ÑJSONת»Ø³ÉbeanºÍDynaBean¡£
ÏÂÔصØÖ·:http://json-lib.sourceforge.net/
»¹ÒªÐèÒªµÄµÚ3·½°ü:
org.apache.commons(3.2ÒÔÉÏ°æ±¾)
org.apache.oro
net.sf.ezmorph(ezmorph-1.0.4.jar)
nu.xom
1¡¢List
Java´úÂë
boolean[] bool ......
ѧµ½JAVAµÄÃæ¶Ô¶ÔÏ󣬷¢ÏÖÈç´ËÇ¿´ó£¡
ÍòÎï½Ô¶ÔÏó£¬ÍòÎïΪÎÒËùÓã¡
¶ÔJAVA²úÉúÇ¿ÁҵĺøУ¡
µ«¶ÔÓÚSun¹«Ë¾µÄÊÕ¹º£¬JAVA²»Öª»áÈçºÎ£¿
--------------------------------------------------
ÕâµÚһƪÎÄÕ£¬ÊÇÎÒÔÚCSDNµÄ¿ª¶Ë¡£
Ö®ºóÎÒ»á¸üÐÂÎҵIJ©¿Í£¬Ð´ÉÏһЩѧϰ¸ÐÊÜ¡£
Ï£ÍûÄÜÔÚÕâÀïÕÒµ½Ò»Æ¬ÐµÄÌìµØ£¡ ......
StringTokenizer Õâ¸öÀàÆäʵÕæÕýÏîÄ¿ÀïÃæ¿ÖźÜÉÙ»áÓðɣ¿µ«ÊÇÕâ¸öÀàÕæµÄºÜʵÓã¬ÒòΪËü¿ÉÒÔ¸ù¾Ý×Ô¼ºµÄ·½Ê½°´ÕÕÒ»¶¨µÄ¹æÔòÀ´²ð·ÖÒ»¸ö×Ö·û´®
String s = new String("The Java platform is the ideal platform for network computing");
//ĬÈϵĹ¹Ô캯Êý£¬»á ......
½ñÌìÀ´½²Ï¹ØÓÚJavaÒì³£ÎÊÌâ¡£ÆäʵÔÚ¿ª·¢¹ý³ÌÖÐJavaµÄÒì³£´¦Àí²¢Ã»ÓÐÏëÏóÖеÄÄÇô¼òµ¥£¬¼òµ¥µÄ˵Java²»×ãÖ®´¦£¬ÄÇôÒì³£´¦Àí»úÖÆÒ²¿ÉÒÔËãÒ»¸ö£¨¸öÈ˹۵㣩¡£ÎªÊ²Ã´ÎÒ»áÕâÑùÈÏΪÄØ£¿ÏÂÃæÎÒ½«ÔÚ¿ª·¢¹ý³ÌÖÐÓÃ×Ô¼ºµÄ˼ά·½Ê½À´½âÊÍÏÂÒ쳣ʹÓá£
JavaµÄÒì³£´óÖ·ÖΪ3Àࣺ
ExceptionÀà¡¢RuntimeExceptionÀàºÍErrorÀ࣬£¨¾ßÌåÒâË ......