简体   繁体   English

访问被拒绝(“java.io.FilePermission”“execute”)

[英]access denied (“java.io.FilePermission” “execute”)

I am beginner.it is first applet that i writing 我是初学者。这是我写的第一个小程序

i want run exe application with applet 我想用applet运行exe应用程序

java code java代码

 package appletexample;

import java.io.*;
import java.awt.*;
import java.applet.Applet;

public class Welcome extends Applet {

    public void init() {
        String execommand = "C:\\windows\\notepad.exe" ;
        try {
            Process proc =  Runtime.getRuntime().exec(execommand) ;
        }
        catch(IOException ieo) {
            System.out.println("Problem starting " + execommand) ;
        }
    }
} 

java.policy.applet java.policy.applet

grant {
  permission java.security.AllPermission;
};

i run this code in eclipse Run As->Java Applet worked and opened NotePade but when Export->Jar File(with .classPath,.project,java.policy.applet) and use in 我在eclipse中运行此代码Run As->Java Applet工作并打开NotePade但是当Export->Jar File(with .classPath,.project,java.policy.applet)并使用

Html HTML

<applet archive="test.jar" code="appletexample/Welcome.class"  width=550 height=300>

in firefox say error access denied ("java.io.FilePermission" "execute")? 在Firefox中说错误访问被拒绝(“java.io.FilePermission”“执行”)? how can fix this problem? 怎么能解决这个问题? 首先是firefox在此输入图像描述 download my java and Html code 下载我的java和Html代码

As beginner you should start with something much much simpler. 作为初学者,你应该从更简单的事情开始。 When you play with Applets not all security rules apply. 当您使用Applet时,并非所有安全规则都适用。 But when you come to real world (Browser in your case or, in other terms, sandbox) security rules are in force to prevent your code from harming the host computer. 但是,当你来到现实世界(在你的情况下浏览器,或者,在其他方面,沙箱)安全规则是有效的,以防止你的代码伤害主机。

What you are doing - you are running some program on the client computer when the client opens your web page with an Applet. 你在做什么 - 当客户端用Applet打开你的网页时,你正在客户端计算机上运行一些程序。 That what viruses do. 病毒的作用。 People will not want to allow it. 人们不会想要允许它。

Of course you can the use Signed Applet approach or other ways to run program on another computer, but is it your goal? 当然你可以使用Signed Applet方法或其他方式在另一台计算机上运行程序,但这是你的目标吗? If it is to learn basics, then run easy stuff. 如果要学习基础知识,那么运行简单的东西。 Eventually, you will understand JNLP (Java Web Start) and other methods useful for you and your clients. 最后,您将了解JNLP(Java Web Start)以及对您和您的客户有用的其他方法。

I assume that you just want to practice how to write a applet. 我假设您只想练习如何编写applet。 For development purpose, you can create a keystore and then use it to sign your applet.jar. 出于开发目的,您可以创建密钥库,然后使用它来为您的applet.jar签名。

Go: Start Menu > Execute > cmd.exe 转到:开始菜单>执行> cmd.exe

Input: 输入:

cd /
keytool -genkey -dname "cn=CN, ou=OU, o=O, l=L, st=ST, c=C" -alias mykey -keypass mypass -keystore mystore -validity 3650 -storepass mypass
jarsigner -keystore c:\mystore -storepass mypass C:\path\to\applet.jar mykey

Then: 然后:

Refresh your HTML page. 刷新HTML页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.io.FilePermission - 访问被拒绝 - java.io.FilePermission - access denied 访问被拒绝(“ java.io.FilePermission”) - access denied (“java.io.FilePermission”) 已签名的Java Applet访问被拒绝java.io.FilePermission读取 - Signed Java Applet access denied java.io.FilePermission read Java RMI 教程 - AccessControlException:访问被拒绝 (java.io.FilePermission - Java RMI Tutorial - AccessControlException: access denied (java.io.FilePermission java.security.AccessControlException: 访问被拒绝 (java.io.FilePermission - java.security.AccessControlException: Access denied (java.io.FilePermission 访问被拒绝(“ java.io.FilePermission”“ [文件路径]”“删除”) - access denied (“java.io.FilePermission” “[file path]” “delete”) Facebook API:访问被拒绝(java.io.FilePermission 读取) - Facebook API: access denied (java.io.FilePermission read) 访问被拒绝(“java.io.FilePermission”“ <filename> “”读“” - access denied (“java.io.FilePermission” “<filename>” “read”) Java.security.Access.ControlException:访问被拒绝(“java.io.FilePermission”“[object file]”“read”) - Java.security.Access.ControlException: access denied(“java.io.FilePermission” “[object file]” “read”) java.security.AccessControlException:GAE上的访问被拒绝(“ java.io.FilePermission”“ C:\\ tempFolder”“ read”) - java.security.AccessControlException: access denied (“java.io.FilePermission” “C:\tempFolder” “read”) on GAE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM