P
paco
Greetings everybody,
I am having all kind of problems with JNI...
First it seems that in order to start the VM machine I have to use an
absolute path to the VM machine. "C:\\Program
Files\\Java\\jre1.5.0\\bin\\client\\jvm" ...
Now my problem is that FindClass doesn't seem to work at all no matter
what class I try to find. I even tried to set an absolute path to be
sure it's not a path or a name thing.
Can anybody tell me what I am doing wrong ?
thanx in advance ...
jclass cls;
jint res=-1;
JNIEnv *pEnv = 0;
JavaVM *pJvm = 0;
LPFNCREATEJVM ProcAddCreateVM;
HINSTANCE hinstLib;
LPFNGETARG ProcAddGetArg;
JavaVMInitArgs vm_args;
JavaVMOption options[1];
options[0].optionString = "-verbose:jni";
vm_args.version = JNI_VERSION_1_2;
vm_args.options = options;
vm_args.nOptions = 1;
vm_args.ignoreUnrecognized = 0;
hinstLib = LoadLibrary("C:\\Program
Files\\Java\\jre1.5.0\\bin\\client\\jvm");
if (hinstLib != NULL)
{
ProcAddCreateVM = LPFNCREATEJVM (GetProcAddress(hinstLib,
"JNI_CreateJavaVM"));
ProcAddGetArg = LPFNGETARG
(GetProcAddress(hinstLib,"JNI_GetDefaultJavaVMInitArgs"));
if (ProcAddGetArg)
{
res = ProcAddGetArg(&vm_args);
if (ProcAddCreateVM != NULL)
{
res = ProcAddCreateVM(&pJvm, (void**)&pEnv, &vm_args);
}
}
FreeLibrary(hinstLib);
}
if (res < 0)
{
fprintf(stderr, "Can't create Java VM\n");
return -1;
}
jthrowable e;
cls = pEnv->FindClass("C:\\SyntagmaticAnalyzer");
//At this point : cls = 0 and got an Exception raised
e = pEnv->ExceptionOccurred();
if (e)
{
pEnv->ExceptionDescribe();
}
I am having all kind of problems with JNI...
First it seems that in order to start the VM machine I have to use an
absolute path to the VM machine. "C:\\Program
Files\\Java\\jre1.5.0\\bin\\client\\jvm" ...
Now my problem is that FindClass doesn't seem to work at all no matter
what class I try to find. I even tried to set an absolute path to be
sure it's not a path or a name thing.
Can anybody tell me what I am doing wrong ?
thanx in advance ...
jclass cls;
jint res=-1;
JNIEnv *pEnv = 0;
JavaVM *pJvm = 0;
LPFNCREATEJVM ProcAddCreateVM;
HINSTANCE hinstLib;
LPFNGETARG ProcAddGetArg;
JavaVMInitArgs vm_args;
JavaVMOption options[1];
options[0].optionString = "-verbose:jni";
vm_args.version = JNI_VERSION_1_2;
vm_args.options = options;
vm_args.nOptions = 1;
vm_args.ignoreUnrecognized = 0;
hinstLib = LoadLibrary("C:\\Program
Files\\Java\\jre1.5.0\\bin\\client\\jvm");
if (hinstLib != NULL)
{
ProcAddCreateVM = LPFNCREATEJVM (GetProcAddress(hinstLib,
"JNI_CreateJavaVM"));
ProcAddGetArg = LPFNGETARG
(GetProcAddress(hinstLib,"JNI_GetDefaultJavaVMInitArgs"));
if (ProcAddGetArg)
{
res = ProcAddGetArg(&vm_args);
if (ProcAddCreateVM != NULL)
{
res = ProcAddCreateVM(&pJvm, (void**)&pEnv, &vm_args);
}
}
FreeLibrary(hinstLib);
}
if (res < 0)
{
fprintf(stderr, "Can't create Java VM\n");
return -1;
}
jthrowable e;
cls = pEnv->FindClass("C:\\SyntagmaticAnalyzer");
//At this point : cls = 0 and got an Exception raised
e = pEnv->ExceptionOccurred();
if (e)
{
pEnv->ExceptionDescribe();
}