Basic tech stuff

Programming and Linux administration

Archive for January, 2008


Posted by Daniel Brahneborg on 2008 January 30

Jay me!

By using the example from the JNI documentation, fixing the errors, and then figuring out the not entirely obvious command lines for compiling, linking and running it, I now have a C program that can talk to Java.

On my Fedora Core 3 box I had to build and run it like this:

gcc -o runjava runjava.c -L/usr/java/jdk1.5.0_11/jre/lib/i386/client -ljvm
LD_LIBRARY_PATH=/usr/java/jdk1.5.0_11/jre/lib/i386/client ./runjava

I bet there is some nice shortcut for that, like `javaconfig -cflags` or something, but I haven’t found that one yet.

Using JNI doesn’t seem entirely difficult, especially since we’re only going to use very few arguments, and the same method signature for all calls. I hope our customers will like that they don’t have to write plugins in C anymore, but can use nicer languages.

Andra bloggar om: , , .

Posted in programming | Leave a Comment »