Loading a dll which is packed within the Jar file

Hello

I have a jar file called mht.jar and it has a dll called mydll.dll - all packed together using ant.

So, when i do:

java -cp %CLASSPATH%.;mht.jar com.test.MHTTest

I get: Native code library failed to load.

java.lang.UnsatisfiedLinkError: no mydll in java.library.path

This is because i have:

try{

System.loadLibrary("mydll");

}catch (UnsatisfiedLinkError e){

System.err.println("Native code library failed to load.\n" + e);

System.exit(1);

}

}

The program works if i place the mydll.dll file in the working directory. It seems as if it cannot extract and read the dll from within the jar file. How do i do this?

Any help will be much appreciated.

Thanks

pJ

[1020 byte] By [pratimdasa] at [2007-11-26 16:51:11]
# 1
You will have to do it yourself. Use the ClassLoader to get an InputStream on the DLL, and copy it to a temporary directory. Then use System.loadLibrary() (or System.load() as you now know the absolute path to the DLL).
dannyyatesa at 2007-7-8 23:18:50 > top of Java-index,Core,Core APIs...
# 2
Is this the only way to do this? This sound very cumbersome - it easier if i leave the dll in the same working directory!There must be a way or a simple API call to load a dll file from within a jar file.
pratimdasa at 2007-7-8 23:18:50 > top of Java-index,Core,Core APIs...
# 3
Why "must" there be? There isn't.
dannyyatesa at 2007-7-8 23:18:50 > top of Java-index,Core,Core APIs...