wood burning stoves
The moose likes Applets and the fly likes Accessing native code from signed applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Accessing native code from signed applet" Watch "Accessing native code from signed applet" New topic

Accessing native code from signed applet

J. Astin

Joined: Sep 22, 2004
Posts: 1
I am having a hard time getting my applet to access native code. I have an applet in a signed jar that downloads a native dll, then calls System.load() to load the library, then calls a method in that native library. I am doing all of this using AccessController.doPrivileged(). In the web page, I get the prompt about trusting the applet. I am able to download the dll and load the library successfully (can't delete the dll while the browser is open, so it must be loaded), but when I call into the native method, I get an UnsatisfiedLinkError on the method name. I have tested the dll to ensure that the method name is correct by running the code as a local application, and it all works fine. Any ideas on what I'm missing?

JRE 1.4.2
IE 6
Win XP

Any help would be great.

Ben Groeneveld

Joined: Oct 15, 2004
Posts: 1
I am doing this also from an applet which downloads, installs, and loads a dll. My problem was that the applet was part of a package. I did what you did, i.e., test as standalone class, then as standalone applet, and then as applet to resolve. The key was to invoke javah with the package name prepended to the class to generate the right sig. I can send you my source if this is of help. Makefile snippet:

AppcastObject.h: AppcastObject.class
javah $(JAVACFLAGS) -o AppcastObject.h communicast.nappcast.AppcastObject

testharness: all
cp ../../../../AppcastObject.dll ../../../../WrapperAppcastObject.dll .
regsvr32 ./AppcastObject.dll
java $(JAVACFLAGS) communicast.nappcast.AppcastObject
regsvr32 /u ./AppcastObject.dll
I agree. Here's the link: http://aspose.com/file-tools
subject: Accessing native code from signed applet
jQuery in Action, 3rd edition