views:

80

answers:

1

i am getting a problem i have deployed a war file, when i run localy through tomcat it works fine but when i run on another system by giveing my system ip and then project folder e.g

http:\192.168.0.145\DllTest it loads the applet but when i click on a button to load the functionality it is throwing an exception

Exception in thread "AWT-EventQueue-3" java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library: http:\192.168.0.145:8080\DllTest\lib\jinvoke.dll

while it is working fine localy but not in another system. Please tell me what is the problem.

Is it a rights issue or something else.

+2  A: 

You cannot load a DLL on an external host. It has to be an absolute disk file system -as the exception message already hints. Your best bet is to download it manually, create a temp file and load it instead.

File dllFile = File.createTempFile("jinvoke", ".dll");
InputStream input = new URL(getCodeBase(), "lib/jinvoke.dll").openStream();
OuptutStream output = new FileOutputStream(dllFile);
// Write input to output and close streams the usual Java IO way.

// Then load it using absolute disk file system path.
System.loadLibrary(dllFile.getAbsolutePath());
dllFile.deleteOnExit();
BalusC
Balus i am using an applet the inculding its jar in a jsp page i have made this in netbeans, i think there is another way around if i include the dll and then make a war file in netbeans
Java_NewBie
Uhm, your point being...?
BalusC
my point is that there is a dll with the jinvoke pacakge should i include that dll in the lib folder, basically in lib folder there is a jinvoke.jar when i extract that jar file it contains the folder "native" and then jinvoke.dll so my point is that it should extract it and find the jinvoke.dll
Java_NewBie
To be sure, do you have the DLL in `/lib` or `/WEB-INF/lib` folder? The `/WEB-INF` folder is inaccessible by public users. I'd suggest to put the DLL file in the same folder as the JAR file of the applet (and change the above code example to remove `lib/` part).
BalusC
no there is no dll in lib folder, let me check by putting a dll file in it
Java_NewBie
Oh? Where did you expect that the client would find the DLL file? You need to provide the DLL file along with the applet's JAR file.
BalusC
same in the lib folder
Java_NewBie
and now it is giving an exception at my end tooo
Java_NewBie
Exception in thread "AWT-EventQueue-2" java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library: http:\localhost:8080\DllTest\lib\jinvoke.dll
Java_NewBie
I've already answered that problem in my answer. Did you update the applet's code accordingly?
BalusC
hmmmm rite got your point
Java_NewBie
hi Balus, when i call dllFile.deleteOnExit(); method, it cannot delete the file the file still exists there.
Java_NewBie
It will only delete when the JVM exits, not when the applet exits :) If you want to delete it on exit of applet, then make it an applet property and delete it during `stop()`.
BalusC
hmmmm thnx Balus :) i will try this out.
Java_NewBie
Balus i have made a method Stop(){ dllFile.deleteOnExit(); } but still not deleting and with dllFile.delete() not deleting the file
Java_NewBie
I think it is a dll so both will not work i guess
Java_NewBie
Oh it indeed won't work for dll files. Java has to unload it first. Right, better just do it when JVM exits.
BalusC
ok thanks Balus
Java_NewBie
You're welcome. Don't forget to mark an answer accepted if it helped in solving the problem. See also http://stackoverflow.com/faq.
BalusC
minus deleteFileOnExit(), the answer is accepted, it helped me a lot.
Java_NewBie
Balus any email if i want to contact you of any problem regarding java, java technologies, frameworks. i am new to this but have read java :).
Java_NewBie
Just press `Ask Question` button at right top of this page :) Enough people around who want to help -including me.
BalusC
yeah i know that :D, but if more specificaly ask the question only from you i will visit your profile :)
Java_NewBie