• Post Reply Bookmark Topic Watch Topic
  • New Topic

Applet not working  RSS feed

khurram kureshi
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've a simple applet that uses threads and it is not working. i'm using netbeans IDE 4.0 with tomcat. when i run the applet i get the follwoing exception in the appletviewer:

java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThread)

at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at java.security.AccessController.checkPermission(AccessController.java:427)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at sun.applet.AppletSecurity.checkAccess(AppletSecurity.java:138)
at java.lang.Thread.checkAccess(Thread.java:1218)
at java.lang.Thread.setPriority(Thread.java:964)
at java.lang.Thread.init(Thread.java:334)
at java.lang.Thread.<init>(Thread.java:371)
at org.me.hello.MyApplet.start(MyApplet.java:35)
at sun.applet.AppletPanel.run(AppletPanel.java:413)
at java.lang.Thread.run(Thread.java:595)

this is the applet:

import java.applet.*;
import java.lang.*;

public class MyApplet extends Applet implements Runnable{

/** Initialization method that will be called after the applet is loaded
* into the browser.

int x_pos = 10;
int y_pos = 100;
int radius = 20;

RuntimePermission perm;

public void init() { }

public void start() {
// define a new thread
Thread th = new Thread(this);
// start this thread

public void stop() { }

public void destroy() { }

public void run() {// lower ThreadPriority

// run a long while (true) this means in our case "always"
while (true) {
// repaint the applet



/*try {
// Stop thread for 20 milliseconds

} catch (InterruptedException ex) {
// do nothing


// set ThreadPriority to maximum value


public void paint(Graphics g) { // set color

// paint a filled colored circle
g.fillOval(x_pos - radius, y_pos - radius, 2 * radius, 2 * radius);

can somebody guide me as to what should i do? i've tried adding:
permission java.lang.RuntimePermission "modifyThreadGroup";

to my java.policy file, the catalina.policy file and still its not working. any help will be helpful thnx.
Ulf Dittmer
Posts: 42972
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

The message is complaining about "modifyThread", not "modifyThreadGroup", so you could try that. Or, to make it easier, use "*" instead, which also covers the other RuntimePermissions.
Michael Celaya
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I had to do some work with an applet that reads and writes on the local machine, so I signed the applet in a jar file and it works. In the FAQ about applets are some useful links.

I hope this helps.
Best regards,
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!