For JNI on windows we use VC++ compiler. I want to know to use JNI on Linux which compiler has to be used?

Anshul Malvi

hello girija, I am using redhat 7.1 and am using Sun's JDK1.2.2 to compile my native code. BEWARE, if you want to embed a JVM in your native code, you will have to include the correct libraries. I learnt the hard way. Anyway here are the libraries you need to include while creating an executable or shared library. Use the following compile options:

gcc -L /java/jdk1.2.2/jre/lib/i386/classic -L /java/jdk1.2.2/jre/lib/i386/native_threads -ljvm -lhpi -lpthread test.c
Also set the $LD_LIBRARY_PATH env. variable to the directories mentioned above. This will help the C executable load the shared libraries dynamically. This should work. good luck .a