- javac HelloWorld.java
- javah -jni HelloWorld
- gcc -shared HelloWorld.c -o libHelloWorld.so
- export LD_LIBRARY_PATH=.
- java HelloWorld
Or you could use the
official Sun tutorial.
If you're getting errors about "jni.h: No such file or directory" you need to
manually set the include path with something like:
Also, you don't really need to set the java.library.path property in the class.
Try the following shortcut to specify it on the command line:
- gcc -shared -I/usr/java/j2sdk1.4.1_02/include -I/usr/java/j2sdk1.4.1_02/include/linux HelloWorld.c -o libHelloWorld.so
- java -Djava.library.path=:. HelloWorld
I like getting e-mail.
Author: Kevin Septor <kjseptor at colby.edu>
Last Modified: April 5th, 2004