JNI Tip on Linux

Posted on 2010/01/11 by Randall.
Categories: Uncategorized.

I’ve been banging around on a few different things, one being setting up my new Dell Mini 10 to run Ubuntu and to try and get World of Warcraft running on it. Just need to get a driver of some sort to enable the IDE-to-USB cable in Linux.

I like the Mini 10 over the 9 because of the keyboard. You just could not do a lot of programming on the smaller keyboard…the brackets and curly-brackets were on a function key so yeah.

The JNI tip is this…do not use System.loadLibrary(String library_name). On Linux you will need to update either your java.library.path or the Linux library path. The java environment option would be okay, but running inside of Tomcat, I noticed a change in the library path from the context of being called inside a taglib tag, inside of a jsp. Something about this didn’t work well, but once I used the System.load(String filename) call everything worked.

I think what’s going on is that loadLibrary() is using the operating-system’s way of searching for dynamic libraries. Configuring your OS to do this is sometimes difficult or not permissible. It’s best to avoid the trouble and just use load(). But I recommend that you’re working from Eclipse try to set the startup parameters of the JVM…open Windows->Preferences, type “jre” into the search box there…select the Installed JREs option, highlight the one you’re using in the list, and click the Edit button. You will find a textbox there for “default JVM arguments.” Do the “-Djava.library.path=” thing there. If you can get this to work, it’s sort of the preferred way.

Now if I can just figure out how to make this linux-style C code work from a DLL on my Windows machine, I will be all set!

no comments yet.

Leave a comment

Names and email addresses are required (email addresses aren't displayed), url's are optional.

Comments may contain the following xhtml tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>