无法在 IntelliJ 中制作小程序 [英] Unable to make an applet work in IntelliJ

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

问题描述

我是个十足的菜鸟.我只是在学习使用 java 编程.我按照教程在我弟弟的电脑上用IntelliJ Idea创建了以下小程序:

I am a complete noob. I am just learning to program using java. I followed a tutorial and created the following applet in IntelliJ Idea in my brother's computer:

import javax.swing.JApplet;
import java.awt.Graphics;
public class MyFirstApplet extends JApplet {
    public void paint(Graphics g) {
        g.drawString("To climb a ladder, start at the bottom rung.", 20, 90);
    }
}

当我尝试运行它时,IDE 显示:

When i try to run this , the IDE shows:

"Exception in thread "main" java.security.AccessControlException: access denied ("java.io.FilePermission" "C:\Users\Abhirup_2\AppData\Local\Temp\AppletPage6525114136327939228.html" "read")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
    at java.security.AccessController.checkPermission(AccessController.java:559)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
    at java.io.File.isDirectory(File.java:838)
    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:82)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
    at sun.applet.AppletViewer.parse(AppletViewer.java:1103)
    at sun.applet.AppletViewer.parse(AppletViewer.java:1074)
    at sun.applet.Main.run(Main.java:156)
    at sun.applet.Main.main(Main.java:98)
    at sun.applet.AppletViewer.main(AppletViewer.java:1257)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Process finished with exit code 1

但是它在我朋友的 eclipse 计算机上运行良好.请帮忙.

However it runs well in my friend's computer in eclipse. Please help.

更新:有一个帐户,那就是我兄弟的帐户.如果我没记错的话,我正在使用它并且是它应该拥有管理员权限的唯一帐户.

UPDATE: There is a single account and that is my brother's acoount. I am using that and being the only account it should have admiistrator rights if I am not wrong.

推荐答案

您需要使用小程序策略文件,该文件授予作为本地小程序运行的权限,并在策略文件"字段的运行/调试配置中进行设置.

You need to use an applet policy file which grants permission to run as a local applet and set it in your Run/Debug configuration in the "Policy File" field.

它至少应具有以下内容:

It should have at minimum the following:

grant {
    permission java.security.AllPermission;
}

或者你可以使用 IntelliJ 在应用程序 bin 目录中提供的默认一个名为 appletviewer.policy

Or you can use the default one provided by IntelliJ in the application bin directory called appletviewer.policy

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

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