This content has been marked as final. Show 11 replies
There are two ways we have figured to fix the problem you are having.
1) Is there any way you can combine the two applets? Set a flag for which classes are needed by who called the applet...did that make sense?
If you combine the two applets into one, your dll loads in the classloader, therefore, your are running one session and will have no problem with the dll having to load twice.
2) Have a setup applet that loads the dll as the page loads. Set your other two applets so that the do not need to use the dll.
Can you tell me what the functionality of your applets are?
Thanks for your reply =)
Well, i doesnt matter if i put my code in two or one applet the problem remains, i only said it to get it more clear.
The same applet will NOT run in another browser window, because the dll is already loaded. The java plugin uses another classloader for the very same applet in another browser window.
I already have a class that does the dll loading and method calling, the loading is static but that doesnt matter because i cant call methods from another browser window. Its like having one VM for each browser window, you have to init the dll for each browser window, but since the dll has been already loaded through JNI by one classloader you cant use it in another browser window.
My dll does calls to a windows services, i found this
So that explain why, but there is no work around and shared classloaders, im not familar with.
I've got a workaround now. Its not that bad, what i
did was seperate the class which calls the dll. It has its own jar now,
this jar file
is now installed on the client machine and i added it to the classpath of
the java plugin. Now i am able to call this class within my browser and i
dont have any problems with the dll anymore.
The only bad thing about this is, that i have to modify the property file
of the java plugin in every user_home dir to add a customer line as
startup parameter, the classpath of my jar file that is. (because system
classpath != java plugin classpath)
I found that Oracle's JInitiator WILL ALLOW page reloads
for the same shared library as well as different pages using
the same shared library. For those who need to use Sun's
JRE 1.4, you'll need to (1) copy the "client" subdir
as "hotspot" and (2) change the setting in JInitiator to point
to that JRE base path. If Oracle can do it for Sun's product,
why can't Sun do it for Sun's product.... embarrassing to say
Your problems come out when the applet is loaded twice (for instance two copies from different servers or 2 different version of the same applet).
I've found a dirty hack that's to rename the native library and load it again.
There are two RFE on Sun JVM related to your issue. feel free to vote them:
Allow a shared native library to be accessible by more than one classloader (applet): http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4750956
Thank you for the reply.
Let me explain the problem. I have a signed applet which loads a dll. Like all others in this thread I am also facing the "Library already loaded problem". I decided to take the suggestion of "ragwanka" posting No. 4 in this thread.
As per the suggestion I made a separate class to load the dll (called dllloader). I made a signed jar having dllloader. I put an entry in the java plugin classpath as suggested. From the actual applet I am trying to call the function in dllloader. At runtime I am getting the AccessControlException.
Please help. Thanks in advance.
Harish N S
I had this same problem and found a simple fix. All I did was move the .dll loading class to a separate jar. Then I install the jar into the ext folder during the plugin install process. This eliminates the problem with the already loaded dll and you won't have the security issues that you are seeing.
I am very interested in JNI via JAVA applet, since it seems that it is the only way of running c-code on the client side. I have browsed the web quite extensively, and to my suprise only a few material is available to describe the needed steps to get the thing going.
I was wondering if you guys could post (or point me to if they exist) some tutorial code on this topic.
Thanks in advance,