D
DeMarcus
Why can't I put my dll in a jar and load it
just like I load my icons?
Daniel
just like I load my icons?
Daniel
DeMarcus said:Why can't I put my dll in a jar and load it
just like I load my icons?
Boudewijn said:Because dll's are libraries and icons are regular resources.
DeMarcus said:Why can't I put my dll in a jar and load it
just like I load my icons?
Steve said:And what good would a DLL do if you aren't running your Java app on
Windows...?
I'm guessing that most JVMs uses the function LoadLibraryEx for windows
and dlopen for unix. Both of these C functions take a string which
gets mapped to a file (in most cases). Niether of these C functions
know how to load libraries out of jar or zip files.
In order for a java application to load these from a jar, they would
probably have to extract the dll's or SO's from the jar to the
filesystem. You could do this manually in your static initializer if
you really wanted to.
I believe that there is an option to specify native libraries, for use
in webstart applications, downloaded from a webserver. You might take
a look at how webstart does it, or just use webstart for deployment.
Basically, loading executable native code into a process space is
beyond the scope and control of the JVM and the JVM has to fit within
the confines of the OS.
I'm guessing that you are running into some deployment issues. You
might want to describe the environment and the problems you are having.
However, you might just be curious.......
String system = System.getProperty("os.name");
String libExtension =
"Windows".equals(system) ? ".dll" :
"Unix".equals(system) ? ".so"
...;
String mylibName = "myLibrary" + libExtension;
URL libUrl = ResourceLocator.class.getResource(mylibName);
File file = new File(mylibName);
if (!file.exists())
file.createNewFile();
FileReader in = new FileReader(new File(libUrl.getFile());
FileWriter out = new FileWriter(file);
byte[] buffer = new byte[1048];
while(in.available() > 0) {
int read = in.read(buffer);
out.write(buffer, 0, read);
}
out.close();
System.loadLibrary("myLibrary");
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.