Saturday, June 19, 2010

Debugging Applets

Debugging an Applet is a nightmare without Eclipse. That said, if your fully-functioning applet fails to run in your browser, then you have Permissions Issues. This is because the Eclipse environment does not accurately reflect the permissions environment your applet will be thrust into.

You will need to modify your java.policy file (located in something like C:\Program Files\Java\jre6\lib\security\). Information on how to do that can be frustratingly thin, but here's a place to start.

The modifications to might look something like this:
grant codeBase "file:${user.home}/Documents/My Dropbox/Gush/*" {
  permission java.io.FilePermission "${user.home}${/}Documents${/}My Dropbox", "read,write";
  permission java.io.FilePermission "${user.home}${/}Documents${/}My Dropbox${/}-", "read,write,delete";
  permission java.net.SocketPermission "*", "accept,connect,listen,resolve";
  permission java.util.PropertyPermission "net.sbbi.*", "read";
};

The most useful tool for the applet-coder is the java console, which IS available outside of Eclipse. Simply right click on the Java icon in your Taskbar (on Windows at least...) and hit "Open Console". All of your precious System.out.println's are suddenly visible!

1 comment :

  1. Cool, this is interesting! The console is definitely a critical resource that is not often found by new comers to applets.

    ReplyDelete