HP-UX Programmer's Guide for Java 2

Table Of Contents
}
else
fprintf (stdout, "after CreateJavaVM \n");
jni = *env;
vmi = *jvm;
// find the class
fprintf (stdout, "before FindClass\n");
jclass cls=env->FindClass("TestNonJavaCallingJava2");
if (cls == 0) {
fprintf (stderr, "Could not locate class TestNonJavaCallingJava2 in clas\
spath
%s\n", options[0].optionString);
exit(1);
}
else
fprintf (stdout, "after FindClass\n");
// find the method
jmethodID mid=env->GetStaticMethodID(cls, *"printInt", "(I)V");
if (mid == 0) {
fprintf (stderr, "Could not locate method printInt with signature (I)V in th\
e
class TestNonJavaCallingJava.");
exit(1);
}
else
fprintf (stdout, "after GetStaticMethod\n");
fflush (stdout);
// invoke the method
env->CallStaticVoidMethod(cls, mid, 100);
// we are done
jvm->DestroyJavaVM();
}
To compile the program:
aCC -c loadjava.cpp -mt -ext \
-I<java_dir>/include -I<java_dir>/include/hp-ux
Linking the program:
To link the program on PA-RISC:
aCC -z -mt -o loadjava loadjava.o -lpthread
To link the program on Integrity:
aCC -z -mt -o loadjava loadjava.o -lpthread
# allow use of SHLIB_PATH to locate shared libraries required by program
chatr +s enable loadjava
To execute the program, set environment variables. The example is for PA-RISC.
For Integrity SDK 1.3.1.x, substitute IA64 for PA_RISC2.0 in the command below.
For Integrity SDK 1.4.2.x substitute IA64N for PA_RISC2.0 in the command below.
Dynamically loading the Hotspot JVM (SDK 1.3.1.x and 1.4.2.x PA-RISC) 61