49 }
50 }
51
52 // method to exit with a fail status
53 void fail() {
54 if (handle) {
55 closeHandle();
56 }
57 exit(1);
58 }
59
60 // method to handle occurred error and fail
61 void handleError(char *messageTitle, char *messageBody) {
62 fprintf(stderr, "%s: %s\n", messageTitle, messageBody);
63 fail();
64 }
65
66 // method to load the dynamic library libjvm
67 void loadJVM() {
68 char lib[PATH_MAX];
69 snprintf(lib, sizeof (lib), "%s/lib/sparcv9/server/libjvm.so", path);
70 handle = dlopen(lib, RTLD_LAZY);
71 if (!handle) {
72 handleError(dlerror(), "2");
73 }
74 fputs("Will load JVM...\n", stdout);
75
76 // find the address of function
77 *(void **) (&jni_create_java_vm) = dlsym(handle, "JNI_CreateJavaVM");
78 if ((error = dlerror()) != NULL) {
79 handleError(error, "3");
80 }
81
82 fputs("JVM loaded okay.\n", stdout);
83 }
84
85 // method to get created jvm environment
86 JNIEnv* initJVM() {
87 JNIEnv *env = NULL;
88 JavaVMInitArgs vm_args;
89 JavaVMOption options[1];
|
49 }
50 }
51
52 // method to exit with a fail status
53 void fail() {
54 if (handle) {
55 closeHandle();
56 }
57 exit(1);
58 }
59
60 // method to handle occurred error and fail
61 void handleError(char *messageTitle, char *messageBody) {
62 fprintf(stderr, "%s: %s\n", messageTitle, messageBody);
63 fail();
64 }
65
66 // method to load the dynamic library libjvm
67 void loadJVM() {
68 char lib[PATH_MAX];
69 snprintf(lib, sizeof (lib), "%s/lib/server/libjvm.so", path);
70 handle = dlopen(lib, RTLD_LAZY);
71 if (!handle) {
72 handleError(dlerror(), "2");
73 }
74 fputs("Will load JVM...\n", stdout);
75
76 // find the address of function
77 *(void **) (&jni_create_java_vm) = dlsym(handle, "JNI_CreateJavaVM");
78 if ((error = dlerror()) != NULL) {
79 handleError(error, "3");
80 }
81
82 fputs("JVM loaded okay.\n", stdout);
83 }
84
85 // method to get created jvm environment
86 JNIEnv* initJVM() {
87 JNIEnv *env = NULL;
88 JavaVMInitArgs vm_args;
89 JavaVMOption options[1];
|