Reputation: 371
I have a problem when create JVM at JNI_CreateJavaVM method, application just "The program '[4616] VnptTokenCplusplus.exe: Native' has exited with code 1 (0x1).", can anybody explain this for me?
#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);
}
And output:
'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).
Upvotes: 0
Views: 2552
Reputation: 460
I was having the same issue and did two things to solve it:
1- Add the place where jvm.dll lies (should be in the program files\java\jsdk_*\bin\server) to the PATH environment variable on your windows machine
2- Try to change the "-Djava.class.path=." to point to an actual directory or a .jar file (worked for me)
Upvotes: 1