Use applet in html?

I would like to use this applet this applet in an html document. In the example on this site, they use:

<applet code="de.wim.outldd.examples.DragDropTest_Applet" width="150" height="150" alt="Applet1" archive="soutldd.jar"> </applet> 

This does not work when I try. My HTML document is in the middle of the extracted directory. How can I use the applet in html, someone please try this.

Error in console

 java.lang.RuntimeException: java.lang.ExceptionInInitializerError at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ExceptionInInitializerError at de.wim.outldd.OutlookDD.init(OutlookDD.java:73) at de.wim.outldd.examples.DragDropTest_Applet$1.run(DragDropTest_Applet.java:29) at java.security.AccessController.doPrivileged(Native Method) at de.wim.outldd.examples.DragDropTest_Applet.<init>(DragDropTest_Applet.java:26) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission java.io.tmpdir read) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPropertyAccess(Unknown Source) at java.lang.System.getProperty(Unknown Source) at de.wim.outldd.OutlDDNativeLib.loadDllFromResource(OutlDDNativeLib.java:135) at de.wim.outldd.OutlDDNativeLib.loadDll(OutlDDNativeLib.java:104) at de.wim.outldd.OutlDDNativeLib.<clinit>(OutlDDNativeLib.java:62) ... 19 more Exception: java.lang.RuntimeException: java.lang.ExceptionInInitializerError 
+6
source share
3 answers

Your applet is trying to read the temp directory value from the java.io.tmpdir system property, which has been prevailed. Applets run in a sandboxed environment with limited permissions for security reasons. To fix this, redefine the default security policy so that your applet can read the property by setting the property permission in the property - java.util.PropertyPermission . To override the default permissions, define the policy in your userโ€™s .java.policy home file. It is recommended that you modify the user policy file rather than the global policy file in your JRE security directory. See Template below:

 grant codeBase "<code base>" { permission <type> "<target>", "<actions>"; permission <type> "<target>", "<actions>"; ... }; For eg. grant codeBase "http://geosim.cs.vt.edu/geosim/-" { java.util.PropertyPermission "java.io.tmpdir", "read"; ... }; 

Edited by:


I noticed that you already have the applet link indicated in your message at the top. So, I give you a step by step guide to get you started.

Here you go -

  • Copy the file $ JRE_HOME / lib / security / java.policy to your home house (in windows this is c: \ users \ <username>) as a .java.policy file. Pay attention to the previous ".". in the file name.

  • Add the following lines to the end of the .java.policy file:

    grant codeBase "http://www.wilutions.com/outldd/-" {
    permission java.security.AllPermission; };

  • Launch the applet in appletviewer as follows and see if it works. appletviewer http://www.wilutions.com/outldd/example.html

  • Please note that I specify all permissions for the applet for the sake of getting started, but it is potentially unsafe to grant all permissions. You must provide only the necessary permissions. Therefore, I leave it to you to understand it.
+4
source

Have you followed the manual found here and are sure that the paths given are correct for your directory/html page?

What about the applet path JAR file soutldd.jar is this correct?

+1
source

go to Java preferences->advance and enable the Java console so that you can see what happens when you load your applet in HTML.

in the windows

java preferences: control panel -> java

0
source

Source: https://habr.com/ru/post/924012/


All Articles