permaculture playing cards*
The moose likes Spring and the fly likes Spring 3 and load JNI/.so library Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring 3 and load JNI/.so library" Watch "Spring 3 and load JNI/.so library" New topic

Spring 3 and load JNI/.so library

andrea mucci

Joined: Aug 12, 2011
Posts: 4
Hi all

My question is:

how is possible to dinamic load JNI or .so file from spring.
in my project i have a lib where i have added different jar files and all work well but if i add the library jar with a jnilib file ( for example in a mac osx leon ) when i charge the library

i obtain this error
java.lang.UnsatisfiedLinkError: no chilkat in java.library.path

so, have a method to use the jsni or .so library without move de shared library to hava.library.path?

Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

This is handled by the JVM - Spring doesn't really have anything to do with it.

Is this your code or a third party library you are using? If it's your code, you can use System.load() instead of System.loadLibrary() - System.loadLibrary() only loads from the java.library.path, but System.load() can load from any location. Some libraries package their native dependencies inside their JAR, extract them to a pre-defined location, and use System.load() to load them from that location.

If it's a third party library using System.loadLibrary(), it's probably easier to just add to the java.library.path - you can either set the PATH environment variable to point to the directory that contains the library, or specify java.library.path when starting the JVM - this is done by setting the property - by passing -Djava.library.path=... as a command-line argument.

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
andrea mucci

Joined: Aug 12, 2011
Posts: 4
Thank's Nath

mmmm, my problem is that i work with an hosting system, and i can't modify the jvm instances.
the library is JavaCV a wrapper of openCV

anyway, thank's for your help
I agree. Here's the link:
subject: Spring 3 and load JNI/.so library
Similar Threads
Classpath, lib directory, and lots of libraries!
Not able to find .dll file in my java path
using spring to develop java library, needed best practise for configuration?
Any ideas why my class isn't getting found?
MHT format