访问被拒绝(“java.io.FilePermission"“执行") [英] access denied ("java.io.FilePermission" "execute")

查看:40
本文介绍了访问被拒绝(“java.io.FilePermission"“执行")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是初学者,这是我写的第一个小程序

我想用小程序运行 exe 应用程序

java代码

 包小程序示例;导入 java.io.*;导入 java.awt.*;导入 java.applet.Applet;公共类欢迎扩展小程序{公共无效初始化(){String execommand = "C:\\windows\\notepad.exe" ;尝试 {Process proc = Runtime.getRuntime().exec(execommand);}捕捉(IOException ieo){System.out.println("问题开始" + execommand) ;}}}

java.policy.applet

grant {权限 java.security.AllPermission;};

我在 Eclipse 中运行此代码 Run As->Java Applet 工作并打开 NotePade但是当 Export->Jar File(with .classPath,.project,java.policy.applet)并在

中使用

HTML

解决方案

我假设您只是想练习如何编写小程序.出于开发目的,您可以创建一个密钥库,然后使用它对您的 applet.jar 进行签名.

前往:开始菜单 > 执行 > cmd.exe

输入:

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 mypassjarsigner -keystore c:\mystore -storepass mypass C:\path\to\applet.jar mykey

那么:

刷新您的 HTML 页面.

I am beginner.it is first applet that i writing

i want run exe application with applet

java code

 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

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

Html

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

in firefox say error access denied ("java.io.FilePermission" "execute")? how can fix this problem? download my java and Html code

解决方案

I assume that you just want to practice how to write a applet. For development purpose, you can create a keystore and then use it to sign your applet.jar.

Go: Start Menu > Execute > 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.

这篇关于访问被拒绝(“java.io.FilePermission"“执行")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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