This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Accessing native code from signed applet" Watch "Accessing native code from signed applet" New topic
Author

Accessing native code from signed applet

J. Astin
Greenhorn

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.

Thanks
Ben Groeneveld
Greenhorn

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
 
Consider Paul's rocket mass heater.
 
subject: Accessing native code from signed applet