I have wrote my first java applet.
It basically loads some images from my Django webserver and then the user can modify them.
I developed it in Eclipse, and I had no problems at all. When I tried it with a test page, on the java console come out this error:
java.security.AccessControlException: access denied (java.net.SocketPermission www.hyros.net resolve)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1031)
at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Applet2SecurityManager.java:500)
at sun.plugin2.applet.Plugin2Manager$AppletContextImpl.getImage(Plugin2Manager.java:2718)
at java.applet.Applet.getImage(Applet.java:242)
at MapGenerator.getResourceImage(MapGenerator.java:50)
at MapGenerator.init(MapGenerator.java:35)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1637)
at java.lang.Thread.run(Thread.java:662)
Eccezione: java.security.AccessControlException: access denied (java.net.SocketPermission www.hyros.net resolve)
The incriminated piece of code:
for(int i=0; i< numero_immagini; i++) {
try {
URL url = new URL(this.getParameter(IMMAGINE+i));
images[i] = ImageIO.read(url);
floors[i] = Integer.parseInt(this.getParameter(PIANO_IMMAGINE+i));
} catch (IOException ioe) {ioe.printStackTrace();}
}
For the test i tried an image from my local webserver, but the error comes out with every possible link, internal or external.
Thank you in advance.
Unless the applet is signed, it will not be able to access images at a different location other then that of the originating server. Here you could use: