How to loadLibrary() from a Jar file.

I want to package my native code libraries (DLL's and Lib's) inside a Jar file. This Jar file is my package that uses the native code libraries. When client applications use my package I would like them to have access to all the code including the native code.

When the client makes a call to System.loadLibrary() or load() it cannot find the native code if it's in the Jar file. If I take it out and place it next to the Jar file, all is fine. Is it possible to make loadLibrary() and/or load() look at a Jar file?

-dh

[549 byte] By [dhoffer] at [2007-9-26 9:06:48]
# 1

Not directly however you can do the following as part of the load procedure.

If the first attempt to load the library throws an exception do the following.

Open the jar file in your application (see java.util.jar package(?)). Search through the jar until you find a JarEntry that is your dll file. Write that dll file to your hard drive, try to loadLibrary again.

andyba at 2007-7-1 20:13:08 > top of Java-index,Java HotSpot Virtual Machine,Specifications...