tags:

views:

203

answers:

2

I'm working on a source-code visualization project that uses the Processing core library. The processing library has the option to use the jogl OpenGL library to render graphics which really improves performance. However, the JNI files that jogl uses aren't necessarily available at runtime, depending on who is using the project and on what platform.

Currently we just have the user specify if they want to use OpenGL, but it would obviously be much nicer if we could use OpenGL by default and only fall back to software rendering when it's not available. The Processing libraries don't seem to make this easy, you're only supposed to specify a renderer once, and changing renderers gives… novel behavior.

Any idea how to figure out if the necessary JNIs for jogl are available and working at runtime?

+2  A: 

Simple just try to load the class with your ClassLoader using loadClass and catch a ClassNotFound exception and UnsatisfiedLinkError to do fallback functionality.

JProgrammer
If you want to know if the native libraries are available, you want to catch UnsatisifiedLinkError.
JesperE
A: 

The other neat way to make sure you get to use Jogl is to deploy via JNLP. You can include Jogl as a remote dependency and the Java launcher will automatically fetch the appropriate native version.

whatnick