I am developing an app (Sigar) that will be available for download through a web browser by clicking on a link. The application will monitor machine info, and it needs some library files to do so (such as libsigar-x86-linux.so,libsigar-x86-freebsd-5.so).
My plan is put the native files into a JAR first, then when the application is downloaded with JWS, I will
- Unpack the JAR file, including the native libraries to a folder
- Find the current class path as determined when the app is running.
- Finally set the java.library.path relative to the classpath, so that my native libraries can be found.
Currently I am trying to determine the path for the JAR using this code:
String path = MyClass.class.getProtectionDomain()
.getCodeSource().getLocation().getPath();
But I must be doing something wrong because the path returned is the web service path, and not one in the local environment.
Could anyone point out what mistakes I have in my current plan? Thanks.