0

I'm fairly new at Java Applet programming. I have this piece of code:

import java.applet.*;
import java.awt.*;

public class HelloWorldApplet extends Applet
{
   public void paint (Graphics g)
   {

  g.drawString ("Hello World", 25, 50);

   }
}

But I get a bunch of errors which I don't really understand.

Exception in thread "main" java.security.AccessControlException: access denied (java.io.FilePermission /private/var/folders/dm/297zvxwd3vs10nzgwgylhztw0000gn/T/AppletPage2031925998178007660.html read)

at java.security.AccessControlContext.checkPermission(AccessControlContext.java:376)
at java.security.AccessController.checkPermission(AccessController.java:549)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
at java.io.File.isDirectory(File.java:752)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:65)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
at sun.applet.AppletViewer.parse(AppletViewer.java:1085)
at sun.applet.AppletViewer.parse(AppletViewer.java:1056)
at sun.applet.Main.run(Main.java:138)
at sun.applet.Main.main(Main.java:80)
at sun.applet.AppletViewer.main(AppletViewer.java:1239)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

What should I do?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 1
    http://stackoverflow.com/questions/23815134/unable-to-make-an-applet-work-in-intellij – loshad vtapkah Jan 05 '15 at 01:28
  • Long time since it meddled with applets, but I "suspect" that there is an issue with the HTML. Unless you absolutely have to, avoid applets while learning, they carry a bunch of there own issues which are better avoided while you're learning – MadProgrammer Jan 05 '15 at 01:35
  • How did you get an exception if your applet won't compile? – David Conrad Jan 05 '15 at 01:39
  • 1) Why code an applet? If it is due to the teacher specifying it, please refer them to [Why CS teachers should **stop** teaching Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/). 2) Why use AWT? See [this answer](http://stackoverflow.com/questions/6255106/java-gui-listeners-without-awt/6255978#6255978) for many good reasons to abandon AWT using components in favor of Swing. – Andrew Thompson Jan 06 '15 at 01:12
  • @AndrewThompson-SIR, you should fire another blog,this time for for SO moderators to restrict OP to read that blog before posting questions. Your this comment seems everywhere in `applet` tag! ha ha ha ... – Am_I_Helpful Jan 06 '15 at 01:14

0 Answers0