Loading dll from applet

Discussion in 'Java' started by George Anadiotis, Feb 25, 2004.

  1. 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.java:1473)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1368)
    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(PrintApplet.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.java:3639)
    at java.awt.Component.dispatchEvent(Component.java:3480)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
    read.java:197)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)

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

    at java.awt.EventDispatchThread.run(EventDispatchThread.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
     
    George Anadiotis, Feb 25, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anushi
    Replies:
    5
    Views:
    8,946
  2. Rob Love

    applet vs. canvas in applet

    Rob Love, Jul 7, 2003, in forum: Java
    Replies:
    1
    Views:
    642
    Liu, Chunyen
    Jul 7, 2003
  3. Archana
    Replies:
    1
    Views:
    1,398
    Andrew Thompson
    Oct 25, 2004
  4. H. Simpson
    Replies:
    4
    Views:
    328
    H. Simpson
    Aug 3, 2004
  5. Replies:
    1
    Views:
    216
    Laurent Bugnion
    Jun 9, 2006
Loading...

Share This Page