J'ai un problème lors de la création JVM à la méthode JNI_CreateJavaVM, application juste "Le programme" [4616] VnptTokenCplusplus.exe: Native 'est sorti avec le code 1 (0x1). ", Quelqu'un peut-il expliquer cela pour moi?JNI_CreateJavaVM code de sortie -1?
#include <jni.h>
#pragma comment(lib,"jvm");
JNIEnv* Vnpt_JavaCreateVM();
void Vnpt_JavaInvokeClass(JNIEnv* env);
int main(){
JNIEnv* env = 0;
env = Vnpt_JavaCreateVM();
Vnpt_JavaInvokeClass(env);
getchar();
}
JNIEnv* Vnpt_JavaCreateVM() {
jint res;
JavaVM* jvm;
JNIEnv* env;
JavaVMInitArgs args;
JavaVMOption options[1];
args.version = JNI_VERSION_1_2; // JNI_VERSION_1_2 is interchangeable for this example
args.nOptions = 1;
options[0].optionString = "-Djava.class.path=.";
args.options = options;
args.ignoreUnrecognized = JNI_FALSE;
res = JNI_CreateJavaVM(&jvm, (void **)&env, &args);
if(res < 0)
{
}
return env;
}
void Vnpt_JavaInvokeClass(JNIEnv* env) {
jclass mainClass;
jmethodID mainMethod;
mainClass = env->FindClass("com/vnpt/TestJDialog");
mainMethod = env->GetMethodID(mainClass, "tokenNotify", "()V");
env->CallVoidMethod(mainClass, mainMethod);
}
Et sortie:
'VnptTokenCplusplus.exe': Loaded 'D:\Documents and Settings\tandaica0612\Desktop\VDC\BaoCao\Source\VnptToken\VnptTokenCplusplus\DebugX86\VnptTokenCplusplus.exe', Symbols loaded.
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\crypt32.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\msasn1.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\advapi32.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\sechost.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\ole32.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\gdi32.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\user32.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\lpk.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\usp10.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'D:\Documents and Settings\tandaica0612\Desktop\VDC\BaoCao\Source\VnptToken\VnptTokenCplusplus\DebugX86\jvm.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\winmm.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\msvcr71.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\imm32.dll', Cannot find or open the PDB file
'VnptTokenCplusplus.exe': Loaded 'C:\Windows\System32\msctf.dll', Cannot find or open the PDB file
The program '[4616] VnptTokenCplusplus.exe: Native' has exited with code 1 (0x1).
Je vous suggère de mettre quelque chose d'utile dans le bloc 'if (res <0)' avant d'aller plus loin. Ignorer les cas d'échec n'est jamais une bonne idée: comme ici, cela vous donne quelque chose de plus difficile à déboguer. – EJP