×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

help:java 问题

本文发表在 rolia.net 枫下论坛我写了一个java applet 测试 程序 如下:

import java.awt.*;
import java.applet.*;
import java.net.URL;
import java.net.MalformedURLException;

public class Tank extends Applet {
Image image;
String url;
public void init() {

url="http://www.shu.edu.cn/~xyx/img/shnet.jpg" ;
try
{
image=getImage(new URL(url));
}
catch(MalformedURLException e)
{


}
}

public void paint(Graphics g) {
g.drawImage(image, 0, 0,this);

}
}
但执行后在控制台上出现了下面的错务信息,图片没法显示
java.security.AccessControlException: access denied (java.net.SocketPermission www.shu.edu.cn resolve)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at java.security.AccessController.checkPermission(AccessController.java:427)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1023)
at sun.awt.image.URLImageSource.<init>(URLImageSource.java:41)
at sun.applet.AppletImageRef.reconstitute(AppletImageRef.java:33)
at sun.misc.Ref.get(Ref.java:46)
at sun.applet.AppletViewer.getCachedImage(AppletViewer.java:377)
at sun.applet.AppletViewer.getImage(AppletViewer.java:372)
at java.applet.Applet.getImage(Applet.java:234)
at Tank.init(Tank.java:26)
at sun.applet.AppletPanel.run(AppletPanel.java:373)
at java.lang.Thread.run(Thread.java:595)更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / help:java 问题
    本文发表在 rolia.net 枫下论坛我写了一个java applet 测试 程序 如下:

    import java.awt.*;
    import java.applet.*;
    import java.net.URL;
    import java.net.MalformedURLException;

    public class Tank extends Applet {
    Image image;
    String url;
    public void init() {

    url="http://www.shu.edu.cn/~xyx/img/shnet.jpg" ;
    try
    {
    image=getImage(new URL(url));
    }
    catch(MalformedURLException e)
    {


    }
    }

    public void paint(Graphics g) {
    g.drawImage(image, 0, 0,this);

    }
    }
    但执行后在控制台上出现了下面的错务信息,图片没法显示
    java.security.AccessControlException: access denied (java.net.SocketPermission www.shu.edu.cn resolve)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
    at java.security.AccessController.checkPermission(AccessController.java:427)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
    at java.lang.SecurityManager.checkConnect(SecurityManager.java:1023)
    at sun.awt.image.URLImageSource.<init>(URLImageSource.java:41)
    at sun.applet.AppletImageRef.reconstitute(AppletImageRef.java:33)
    at sun.misc.Ref.get(Ref.java:46)
    at sun.applet.AppletViewer.getCachedImage(AppletViewer.java:377)
    at sun.applet.AppletViewer.getImage(AppletViewer.java:372)
    at java.applet.Applet.getImage(Applet.java:234)
    at Tank.init(Tank.java:26)
    at sun.applet.AppletPanel.run(AppletPanel.java:373)
    at java.lang.Thread.run(Thread.java:595)更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • This is security limit for applet: applet can only connect to the host from which it is downloaded
      • so how can I display some images in client computer through applet