the corner office

a blog, by Colin Pretorius

java.library.path

A gotcha. I was trying to load a native library, and to speed things up when fiddling with a test app I tried to set the java.library.path system property directly in the code, before anything else was loaded or instantiated, a la:

System.setProperty("java.library.path", "/usr/lib:/usr/local/lib");

This didn't work, and I still got an error saying:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no myspeciallib in java.library.path

I had to specify the system property on the command line with -Djava.library.path=/usr/lib:/usr/local/lib. Presumably the JVM resolves the library path a lot earlier in life, not just when you try to explicitly load a .dll or .so. Stands to reason I suppose.

{2009.02.14 16:47}

« Pretty

» Virtual losses