Enabling Loading and Saving.

By default the Java plugin will not allow the applet to access data from the system on which it is running.  This is to ensure that malicious code cannot harm your system.  However this also means that potentially useful applications cannot perform simple operations like loading and saving.

Java does provide a way around this which is to grant certain applets explicit permission for them to do certain actions.  This is achieved with a policy file.  This file is named ".java.policy" and on Multiuser systems this is normally placed in the users home directory and on single user windows systems this is usually placed in "c:\windows" .  

To find where the policy file should be placed, for your plugin, enable the java console from your web browser.  When viewing the java console it should give you the option 'dump system properties' which can normally be selected by pressing 's'.  Look for a parameter called user.home, this is where your individual policy file should be placed.

On the York campus machines the ".java.policy" should be placed in the following locations:
Windows 2000: C:\Documents and Settings\{username}\
Windows 95: C:\Win95\Profiles\{username}\
Linux: /usr/{username}/

NB. Windows explorer and other applications may not let you create a file that starts with '.' despite the fact that this is valid windows file naming. You will have to rename the file to ".java.policy" using the console.

Granting File access for the Simulator.
To the contents of your policy file add the following lines:

grant codeBase "http://www-student.cs.york.ac.uk/~njg103/-" {
  permission java.util.PropertyPermission "user.home", "read";
  permission java.io.FilePermission "<<ALL FILES>>", "read, write";
  permission java.lang.RuntimePermission "modifyThread";
};

This will allow read and write access, for the applet, to any file that would normally be accessable to the user.  The property and runtime permissions are required for the operation of the java filechooser.

If you would rather not grant read and write access to your personal filestore, access to the name of your home directory or give the applet the ability to modify threads, there is another option built into the simulator to load and save files by copying and pasting their contents to and from a window.  To allow this kind of file access the following policy should be set up:

grant codeBase "http://www-student.cs.york.ac.uk/~njg103/-" {
  permission java.awt.AWTPermission "accessClipboard";
};

If both permissions are given the program defaults to the standard file methods.

To learn more about java virtual machine security and policy files go to http://java.sun.com