This content has been marked as final. Show 7 replies
You need to link against the JDK library that provides those functions, which is the jvm library
This is a good starting point and it mentions what you need to do to link and compile : http://web2.java.sun.com/docs/books/tutorial/native1.1/index.html
specifically this http://web2.java.sun.com/docs/books/tutorial/native1.1/invoking/invo.html shows the commands needed
Hope this helps,
I get the simlilar error when trying to use the JNI_CreateJavaVM(..), JNI_GetDefaultJavaVMInitArgs(..), how can I set the LD_LIBRARY_PATH on Linux? I just find the "libjava.so" in the lib subdirectory, where do the "libhpi.so" & "libjvm.so" files reside? Some instructions mention that we need to use the "ldconfig" command to link the soname to the real name before setting the LD_LIBRARY_PATH, how about no "ldconfig" command available in linux?
Thanks for any clue,
You can set the LD_LIBRARY_PATH in linux with the follow command :
Replace whatever specific library path you need in the below example!
Red Hat Linux specific format :
export LD_LIBRARY_PATH=<your lib path>:<other paths required>:$LD_LIBRARY_PATH
Another small example :
Only after loading the library environment will you be able to run the JVM successfully.
Your other question on the segmentation core dump is probably due to the fact that you use a (void**) pointer with the old 1.1 vm_args.version. JDK versions lower than 1.2 uses the older interface that is not as portable and takes a JNIEnv pointer in the
JNI_CreateJavaVM(JavaVM* ,JNIEnv **,JDK1_1InitArgs);
method but newer 1.2 uses
JNI_CreateJavaVM(JavaVM* ,void **,JavaVMInitArgs);
Read the updated docs on 1.2 from your JDK distribution and you will realize that the segmentation crush was due to pointer problems. Note also that the code to invoke the 1.2 version and 1.1 versions are different, so read the docs carefully.
I am using the example ie in chap7 of http://java.sun.com/docs/books/tutorial/native1.1/invoking/invo.html ie invoke.c ..
In invoke.c program we are loading jvm for calling java methods in this c program..
while compiling the using the you specified command ie
cc -I/usr/java2/include -I/usr/java2/include/unixware -L/usr/java2/jre/lib/x86at -o invoke invoke.c
i am getting the errors like
belowUndefined first referenced
symbol in file
UX:ld: ERROR: invoke: fatal error: Symbol referencing errors. No output written
tell me how to run and execute the this c function
pls send to email@example.com
it's very Urgent to us..