Compiling and Executing the Program
I've saved the C program we wrote as
In order to compile the program to a
The JNI headers come with the JDK, in its gcc -mno-cygwin -o invoke.exe -I$jdk/include -I$jdk/include/win32 invoke.c -L. -ljvmRecall that I said I was putting everything in one directory. So my libjvm.dll.a is sitting in my
current working directory (hence -L. ), and I can refer to it by name as jvm .
In order to execute the program, we PATH=$jdk/jre/bin/classic:$PATH; invokeIf you want to use HotSpot, it will look something like: PATH=$jdk/jre/bin/hotspot:$PATH; invoke If you have everything set up correctly, you should see: $ PATH=$jdk/jre/bin/hotspot:$PATH; invoke Hello, World! Arguments sent to this program: From-C-programAs long as you manage the PATH variable properly, you should be able to execute the Java program from inside
or outside Cygwin, since we used the -mno-cygwin option on gcc .
Please let me know if you find errors or omissions in this walkthrough, or have general comments or questions. |