Error initializing the HPI library
843829Jul 29 2002 — edited Jul 29 2002Hey all,
I'm sure this must be something stupid that I am doing with my paths or something similar ....
I am trying to create a JVM Instance in a simple C Program and am getting the following error when I run the program,
There was an error trying to initialize the HPI library.
Please check your installation, HotSpot does not work correctly
when installed in the JDK 1.2 Solaris Production Release, or
with any JDK 1.1.x release.
Can't create Java VM
I am using java 1.3 and specifying 1.2 as the JNI version within my source,
I compile the code using
g++ -I ./ -I /usr/local/j2sdk1_3_1_01/include -I /usr/local/j2sdk1_3_1_01/include/solaris -L /usr/local/j2sdk1_3_1_01/jre/lib/sparc -ljvm invoke.cc
My LD_LIBRARY_PATH is
/usr/local/j2sdk1_3_1_01/jre/lib/:/usr/local/j2sdk1_3_1_01/jre/lib/sparc/:/export/hardy/disk2/aidemos/orange/fusionworks3.0/opt/OPENET/lib/:/usr/local/j2sdk1_3_1_01/jre/lib/sparc/native_threads/libhpi.so
My CLASSPATH is
.:/usr/local/j2sdk1_3_1_01/jre/lib/
And my path points to java 1.3 (java -version)
Am I just missing something from my LD_LIBRARY_PATH setting ?
I've attached the source below if that helps at all,
Any help is really appreciated ...
--------------------------------------------------------------
#include "include/jni.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream.h>
main() {
JavaVMInitArgs vm_args;
JavaVMOption options[4];
JNIEnv *env; // pointer to JNI environment
JavaVM *vm; // pointer to Java virtual machine
jint res;
options[0].optionString = "-Djava.compiler=NONE"; /* disable JIT */
options[1].optionString = "-Djava.class.path=./"; /* user classes */
vm_args.version = JNI_VERSION_1_2; //change it to JNI_VERSION_1_2
// for JDK1.3
vm_args.options = options;
vm_args.nOptions = 2;
vm_args.ignoreUnrecognized = JNI_TRUE;
res = JNI_CreateJavaVM(&vm, (void **)&env, &vm_args);
if (res < 0)
{
cerr << "Can't create Java VM\n";
exit(1);
} else {
cerr << "Java VM initialized\n";
}
vm->DestroyJavaVM();
cerr << "Java VM destroyed\n";
}
--------------------------------------------------------------