Setting java.library.path internally

I’ve run into the problem that JOGL is great for my project, but I want to distribute it to my (non-technically-competent) users in a very friendly way. I can’t use Web Start.

The problem is getting the native libraries to be found by the VM. I’m well aware that you can set java.library.path from the command line (but this requires a custom launcher script for every user) or as an environment variable (but this requires configuring the user’s machine). I’d like to do it by “discovering” the location of my program’s jar file (which I can already do), and then doing a System.setProperty(“java.library.path”, …) command, but it’s apparently well known but poorly documented that changes to java.library.path within the program are ignored (see Java bug # 4280189).

Any workarounds for this? The folks at Sun are unlikely to make any changes, it seems, because although this is poorly designed it’s so rarely a problem. I could pre-load the library myself using System.load(), but the loadLibrary() call in net.java.games.jogl.impl.NativeLibLoader$1.run will still fail, so that doesn’t get me anywhere…

Thanks,
Ian

If you’re not using webstart, is it safe to assume you’re using some sort of installer program? Could you then use the installer to hunt out and find the JRE ext dir and put the Jogl files in there manually? Not a totally system-friendly approach but if you’re aiming to do it totally automatically then it may be an acceptable solution.

There’s no need to set it. Just make sure the DLLs are in the same directory as the JOGL JAR and it works fine. We do this all the time with our applications.

[quote]There’s no need to set it. Just make sure the DLLs are in the same directory as the JOGL JAR and it works fine. We do this all the time with our applications.
[/quote]
AFAIK this works just for Windows. On Linux etc I think you’ll need a one line starter script. For example see Ken’s comments here: http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=jogl;action=display;num=1082800790

If there’s an even simpler way for Linux, Mac, etc. please tell us. :slight_smile:

It works that way on my Mac as well – I can just put jogl.jar and libjogl.jnilib in the directory, and away we go. So it’s really just Linux (and possibly Solaris?) that’s being backwards :wink:

Thanks for the info: good to know!

[quote]So it’s really just Linux (and possibly Solaris?) that’s being backwards :wink:
[/quote]