9 Replies Latest reply on Oct 4, 2013 2:53 PM by gimbal2

    Java Applet


      Dear all,


      I have created one aspx application to get client system information.  For getting the client system information,  i have created a JNI library.


      I have used java script to load a applet jar which in-turns will load the JNI library where the JNI library is located in every client system.


      I have tested this application and it is working fine.


      For testing purpose, i have hosted my application in two to three system.  For eg, Server A, B and C.  I had access the server pages in a system (TEST system).


      When i access the page from system A and C in the TEST system, the application works fine.


      But when i access the page from system B in the TEST system, the java script gives error.


      The error is  object does not support this method or property in the line Obj.GetUserName().


      Sample source is below:


      Java script:

      document.write('<applet code="Client.Information.class" width="0" height="0" MAYSCRIPT archive="Client.jar" id="Obj"></applet>');


      function ClientInformation ()






      Applet jar:


      package Client;


      import java.*;

      import java.io.*;

      import java.lang.*;

      import java.applet.Applet;

      import java.awt.*;

      public class Information extends Applet


           public native string GetUserName();

           public native string GetSystemMemory();








      As surfing through internet, updating the java version and clearing the browser cache will solve this problem.  But i have tried this.


      Please guide me to solve this error.


      Thanks for your  reply.

        • 1. Re: Java Applet

          Google how to use JNI in an applet - you can't just do that, there are all kinds of security layers in your way and depending on the version of Java those layers will be either strict or incredibly strict. As far as I know, even in a signed applet you can't just call loadLibrary, you need to go through an AccessController. Now I've given you stuff to google.

          • 2. Re: Java Applet

            Thanks for your reply.


            As far as security concern, i have disabled the java security (Control Panel->Java Control Panel->Advanced->Mixed Code->Disable Verification). Still the error coming.

            • 3. Re: Java Applet

              And it will keep coming until you properly inform yourself. Just trying stuff won't work. To quote someone I respect: You don't write code by banging your head on the keyboard.

              • 4. Re: Java Applet

                Is your jar signed? Do you use AccessController as suggested? What you did in the Control Panel does not disable the applet security, only a certain aspect of it.

                Does the java console show something? Is it an inability to access the java method or something fishy happens inside the java method? (Hint: try to empty the method and see if the same happens.)

                Since it works with two servers and not the third, are the deployments identical 100%. If not, what are the differences?

                • 5. Re: Java Applet

                  1) Yes, i have properly signed the jar file.

                  2) I will try with Access Controller as suggested.

                  3) The java does not show any error.

                  4) Can you please explain this "Hint: try to empty the method and see if the same happens"?

                  5) All the three server are identical (Different can be in OS and RAM).  Another point is that the about error will pop suddenly in the working server also.

                  • 6. Re: Java Applet

                    About the hint. I am curious if the java method can be accessed from your javascript. An empty java method that 'works', would show that the problem is not a javascript-to-java communication, but something that your java method does. If this is the case, you can narrow down what happens wrong in your java method, using a debugger or System.out.println's. From your last post, I suspect more and more that your DLL has a bug that sometimes does not cause problems, sometimes does (for instance, accessing a memory location that it shouldn't).


                    By the way, in javascript-to-java-to-native calls, AccessController.doPrivileged() is a must. I wonder how it sometimes works.

                    • 7. Re: Java Applet

                      now they tell me. Could have saved me a ton of money on new keyboards and painkillers had I known that when I started programming

                      • 8. Re: Java Applet

                        A former colleague of mine had a theory that computers should have a Sorry! key on the keyboard, that when you pressed it, it would just say 'sorry!'. It would save on a lot of Panadol.

                        • 9. Re: Java Applet

                          baftos wrote:


                          By the way, in javascript-to-java-to-native calls, AccessController.doPrivileged() is a must. I wonder how it sometimes works.

                          Exactly that.