在html中使用小程序? [英] Use applet in html?

查看:75
本文介绍了在html中使用小程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在HTML文档中使用此小程序此小程序.在此站点上的示例中,他们使用:

I would like to use this applet this applet in a 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>

尝试时不起作用.我的HTML文档位于提取的目录中间.如何在html中使用小程序,请尝试一下.

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

控制台中的错误

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

推荐答案

您的小程序正在尝试从 java.io.tmpdir 系统属性中读取临时目录值这是有特权的.由于安全原因,小程序在具有受限权限的沙箱环境中运行.要对其进行修复,请覆盖默认的安全策略,以通过在属性上设置属性权限- java.util.PropertyPermission 来允许您的小程序读取该属性.要覆盖默认权限,请在用户主目录的.java.policy文件中定义策略.建议您编辑用户特定的策略文件,而不是JRE安全目录下的全局策略文件.请参考下面的模板:

Your applet is trying to read the temp directory value from the java.io.tmpdir system property which is previleged. Applets run in a sandbox environment with restricted permissions beacause of security reasons. To fix it, override the default security policy to allow your applet to read the property by setting the property permission - java.util.PropertyPermission, on the property. To override default permissions define the policy in your user home's .java.policy file. It is recommended that you edit your user specific policy file and not the global policy file under your JRE security directory. Refer the template below:

grant codeBase "<code base>" { 
   permission <type> "<target>", "<actions>"; 
   permission <type> "<target>", "<actions>"; 
   ... 
}; 

For eg. 
grant codeBase "http://geosim.cs.vt.edu/geosim/-" { 
  permission java.util.PropertyPermission "java.io.tmpdir", "read";
  ... 
}; 



我注意到您已经在顶部的帖子中指定了applet链接.因此,我正在逐步指导您入门.


Edited:


I noticed that you already have the applet link specified in your post at the top. So, I am giving a step by step guide to get you started.

您在这里-

  1. 将$ JRE_HOME/lib/security/java.policy文件复制为您的用户主目录(在Windows上为c:\ users \ <用户名>),以 .java.policy 文件. 请注意前面的."在文件名中.

  1. Copy $JRE_HOME/lib/security/java.policy file to your user home (on windows it is c:\users\< user name>) as .java.policy file. Please note the preceding "." in the file name.

将以下行添加到.java.policy文件的末尾:

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

授权代码库" http://www.wilutions.com/outldd/- " {
权限java.security.AllPermission; };

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

按以下步骤在appletviewer中运行该applet,然后查看它是否有效. appletviewer http://www.wilutions.com/outldd/example.html

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

这篇关于在html中使用小程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆