Hi,
I wish to load my native libs from my applet, which is a signed jar.
The "problem" is in run time maybe I don't know the library exactly name, because:
- for windows I can have 2 .dll -s: MyNative.dll -for release and MyNatived.dll as debug version
- for Linux the extension isn't .dll , it is .so
- and for Mac I don't know the extension yet.
The native libs(all) are packed into jar root.
I have a written code sample which do something, but not as I wish:
try {
JarFile jarFile = new JarFile(*jarfile*);
Enumeration enumEnntries = jarFile.entries();
while (enumEnntries.hasMoreElements()) {
process(enumEnntries.nextElement(), jarFile);
}
} catch (Exception ex) {
ex.printStackTrace();
}
First problem/question how can I get the jarfile corrrect value? - for test proposes I give it an absolute path : "D:\\work\\.....MyJarWithApplet.jar"
private void process(Object obj, JarFile jarFile) {
JarEntry entry = (JarEntry) obj;
String name = entry.getName();
long size = entry.getSize();
long compressedSize = entry.getCompressedSize();
//System.out.println(name + "\t" + size + "\t" + compressedSize);
// here I have acccess to the entry name so, dll, debug dll. Here I know which dll I have in jar
if(name.startsWith("MyNativeLibPrefix"){
// than extract this entry to the System.getProperty("java.io.tmpdir")
.....
// after extract: load the lib
System.load(myExtractedFile.getAbsolutePath());
}
}
There are better solution for this problem?
How can I give the correct value for the new JarFile(*jarfile*); ?
Edited by: matheszabi on 2009.12.14. 12:50