Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Loading dll from applet

Reply
Thread Tools

Loading dll from applet

 
 
George Anadiotis
Guest
Posts: n/a
 
      02-25-2004
Hello all

This one has been posted at Sun's site forums as well, but since i got
no reply from there i thought i'd try my luck here as well. So here
goes:

I am trying to develop an applet whose funtionality includes loading a
..dll library and invoking some function implemented as native code.
The dll implementation is actually third-party, but i am pretty
confident there's nothing wrong with it because it works fine when
invoked in a standalone application.

Before going any further, i should note that i am aware of security
restrictions, signing applets etc - i have temporarily bypassed that
limitation during development by granting a
java.security.AllPermission permission in my JRE policy file.

In fact, the dll itself even works fine when invoked from the applet
source directory - i.e. directory source contains the applet class
file and the dll file, so when opening the applet using appletviewer
and a test html page that contains something like this: <APPLET
CODE='PrintApplet.class' WIDTH=426 HEIGHT=322>, everything works fine.

Trouble starts when i try to package the applet source and the dll
into a jar file and open it again using the same procedure, only this
time using something like this in my html:
<APPLET CODEBASE="C:/testdir/PrintApplet" archive="PrintApplet.jar"
CODE="PrintApplet" WIDTH=426 HEIGHT=322>

In this scenario, the dll is loaded using:
InputStream in = this.getClass().getResourceAsStream("ShellExec.dll ");

and then saved on the client disk using a FileOutputStream.

What happens then is that i get the following stacktrace:

java.lang.UnsatisfiedLinkError: C:\testdir\PrintApplet\ShellExec.dll:
Invalid access to memory location
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.jav a:1473)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java :136
at java.lang.Runtime.load0(Runtime.java:737)
at java.lang.System.load(System.java:809)
at ShellExec.<clinit>(ShellExec.java:19)
at PrintApplet.testPrint(PrintApplet.java:200)
at PrintApplet.clearButton_ActionPerformed(PrintApple t.java:215)
at PrintApplet$SymAction.actionPerformed(PrintApplet. java:159)
at java.awt.Button.processActionEvent(Button.java:381 )
at java.awt.Button.processEvent(Button.java:350)
at java.awt.Component.dispatchEventImpl(Component.jav a:3639)
at java.awt.Component.dispatchEvent(Component.java:34 80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 450)
at java.awt.EventDispatchThread.pumpOneEventForHierar chy(EventDispatchTh
read.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThre
ad.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:144)

at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:136)

at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:99)


This seems to suggest that the dll is actually loaded, but then
something gives. Any ideas as to what may be the issue here?

Thanks in advance,
George Anadiotis
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
display a message that Applet is loading! while applet loads shaillenkumar@gmail.com Javascript 1 06-09-2006 08:24 AM
How to determine if a DLL is a COM DLL or .NET DLL Anushi ASP .Net 5 10-28-2004 01:59 PM
Java Applet loading in Applet Viewer but not in HTML page Archana Java 1 10-24-2004 11:41 PM
mprapi.dll --> samlib.dll --> ntdll.dll issue. Some1 Computer Support 4 04-05-2004 02:02 AM
msvcrt.dll, msvcirt.dll, msvcrt20.dll and msvcrt40.dll, explanation please! Snoopy NZ Computing 16 08-25-2003 12:34 PM



Advertisments