InOnIt.com
Cygwin/Java
Calling C from Java
Organizing for JNI
Writing the HelloWorld class
Creating a .h file
Writing the C function
Loading the DLL into the JVM
Running the program
NEW!World Football Rankings & World Cup Odds
David's Company

Execute the Java Program

At this point, we can execute the program we created:

java -classpath [whatever] example.jni.HelloWorld
Again, we need to have the DLL in our java.library.path, either by:
  • Executing it from the directory in which the DLL is located,
  • Placing HelloWorld.dll into one of the directories in the Windows PATH,
  • Changing the java.library.path via the -D command-line option on java.exe.

If everything's working fine, we should get:

Hello World!

Hooray! 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.