Setting the working directory of a Java Applet
I have two signed Jars, a.jar and b.jar. a.jar is launched as an applet inside the browser and b.jar is in Appdata/locallow/xyz (Vista). a adds b to it's classpath and calls some functions of b.jar. So far so good. Now b unpacks some dlls into the working directory and depends on them. It must be the working directory, because the dlls reference each other, so no alternative directory is possible. The bad thing is, that the working directory (user.dir) in Firefox is "c:\program files\mozilla firefox"... So my appli开发者_JS百科cation works as long as the user has admin-rights. But as soon as a normal user launches the applet, it crashes as the application wants to unpack the dlls. And it really isn't nice to have application-dlls in the directory of Firefox anyway... A solution would be to set the working directory to the dir, where b.jar is. Is this possible in any way?
The applet approach is not well suited for native libraries.
I would suggest considering Java Web Start which contains support for DLL's directly. It was reworked in Java 6 to work well with applets too.
精彩评论