Tool for testing the loading of native libraries in Java

A lot of Java libraries are no longer pure Java, they quite often are wrappers around other native libraries, making them available to Java developers. This is all fine, until you run into the problem that libraries cannot be located and your application simply exits (since the naughty library developers are using a hard System.exit(x) call). The larger your application, then longer it will take to get to the point where it tanks. Sometimes, especially when migrating to a new server, it is useful to just test whether all your native libraries are present and your application will work (well, at least from the native library point of view).

With that in mind, I created a tiny library called loadlib4j, which allows you to quickly test from the command-line, whether libraries are present or not.

You can run it like this to look for the Intel MKL runtime library, which needs to be on LD_LIBRARY_PATH under Linux (for Windows, the mkl_rt.dll library must on the PATH):

java -jar loadlib4j-0.0.1.jar

This will output something like this: false
libmkl_rt: false
mkl_rt: true

The tool automatically tests loading the library without extension and lib prefix as well. So you don’t have to be too careful. 😉

You can supply as many libraries as arguments to the tool as you wish.

Leave a Comment

Your email address will not be published. Required fields are marked *