Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing native code from signed applet

 
J. Astin
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!