您好 stackoverflow 用户!我想从我的 java 小程序中知道这段代码有什么问题:
for (int i = 0; i < 12; i++)
{
try {
JOptionPane.showMessageDialog(null, "CodeBase: " + getCodeBase());
JOptionPane.showMessageDialog(null, "Earl: " + new URL(getCodeBase(), "../animation/MonkeyAnimX" + String.valueOf(i) + ".jpeg"));
preparedartwork[i] = getImage(new URL(getCodeBase(), "../animation/MonkeyAnimX" + String.valueOf(i) + ".jpeg"));
} catch (MalformedURLException ex) {
ex.printStackTrace();
}
}
当抛出异常时,它说:
java.security.AccessControlException: access denied (java.io.FilePermission /var/www/animation/MonkeyAnimX0.jpeg read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:399)
at java.security.AccessController.checkPermission(AccessController.java:558)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
at sun.awt.image.URLImageSource.<init>(URLImageSource.java:55)
at sun.applet.AppletImageRef.reconstitute(AppletImageRef.java:51)
at sun.misc.Ref.get(Ref.java:64)
at sun.applet.AppletViewer.getCachedImage(AppletViewer.java:395)
at sun.applet.AppletViewer.getImage(AppletViewer.java:390)
at java.applet.Applet.getImage(Applet.java:259)
at MonkeysTyping.init(MonkeysTyping.java:213)
at sun.applet.AppletPanel.run(AppletPanel.java:437)
at java.lang.Thread.run(Thread.java:679)
为了确保不会因为缺少权限而引发此异常,我对其进行了更改,以便每个人和 -thing 都拥有操作这些文件的所有权限。(-> cmod 777) 我从教程中得到了这段代码,有什么问题吗?