3 Replies Latest reply on Aug 29, 2002 1:31 AM by 843811

    Question about Signed Applets with JNI

    843811
      I have a Signed Applet to call a native dll (InstanceMethodCall) .But when i run it , it 's prompt following Error Message. I think that java.policy is not correct .Who can give me some options . Thanks!

      java.lang.ExceptionInInitializerError: java.security.AccessControlException: ac
      ess denied (java.lang.RuntimePermission loadLibrary.InstanceMethodCall)
      at java.security.AccessControlContext.checkPermission(AccessControlCont
      xt.java:272)
      at java.security.AccessController.checkPermission(AccessController.java
      399)
      at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
      at java.lang.SecurityManager.checkLink(SecurityManager.java:837)
      at java.lang.Runtime.loadLibrary0(Runtime.java:743)
      at java.lang.System.loadLibrary(System.java:820)
      at HelloWorld.<clinit>(HelloWorld.java:26)
      at java.lang.Class.newInstance0(Native Method)
      at java.lang.Class.newInstance(Class.java:237)
      at sun.applet.AppletPanel.createApplet(AppletPanel.java:579)
      at sun.applet.AppletPanel.runLoader(AppletPanel.java:515)
      at sun.applet.AppletPanel.run(AppletPanel.java:293)
      at java.lang.Thread.run(Thread.java:484)


      My java.policy:(I put it in D:\Documents and Settings\zuoqiang.zhang , My platform is win2k )

      grant codeBase "http://j2k-zqzhang/*" {
      permission java.security.AllPermission;
      };
      grant codeBase "file:///F:/temp/tf/InstanceMethodCall/Applet/-" {
      permission java.security.AllPermission;
      };
      grant signedBy "darcyzhang" {

      permission java.security.AllPermission;

      };

      A script that creates a darcyzhang identity :

      set JAVA_HOME=c:\bea\jdk131

      set MYCLASSPATH=
      set PATH=
      set MYCLASSPATH=.;%JAVA_HOME%\lib\tools.jar
      set PATH=%WL_HOME%\bin;%JAVA_HOME%\bin;%PATH%

      %JAVA_HOME%\bin\javac -d . -classpath %MYCLASSPATH% *.java

      %JAVA_HOME%\bin\keytool -genkey -alias darcyzhang -dname "cn=darcyzhang, ou=JavaSoft, o=Sun Microsystems, c=us" -keystore keystore. -storepass darcyzhang -keypass darcyzhang -validity 1000

      %JAVA_HOME%\bin\keytool -export -alias darcyzhang -rfc -file darcyzhang.x509 -keystore keystore. -storepass darcyzhang

      %JAVA_HOME%\bin\jar cfv HelloWorld.jar HelloWorld.class HelloWorld.html InstanceMethodCall.dll

      %JAVA_HOME%\bin\jarsigner -verbose -keystore keystore. -storepass darcyzhang HelloWorld.jar darcyzhang


      %JAVA_HOME%\bin\jar tvf HelloWorld.jar


      %JAVA_HOME%\bin\keytool -import -alias darcyzhang -file darcyzhang.x509


      %JAVA_HOME%\bin\keytool -list -keystore keystore -storepass darcyzhang


      %JAVA_HOME%\bin\appletviewer helloworld.html