title: .java.policy file and local applet
body: <p>I am working on an HTML page that is using Javascript to interact with a Java applet.  The HTML page, javascript files, and .jar file for the applet will be deployed locally to a folder on the user's filesystem.</p>
  
  <p>(Implmenting this as a standalone Java application is not an option here; for various reasons I will not explain here).</p>
  
  <p>The applet needs to do local file i/o.  As such, I'm attempting to tweek the settings in the user's .java.policy file to permit this.</p>
  
  <p>I have found the following setup is the only one that works:</p>
  
  <pre><code>grant 
  {
    permission java.io.FilePermission "&lt;&lt;ALL FILES&gt;&gt;", "read";
    permission java.io.FilePermission "&lt;&lt;ALL FILES&gt;&gt;", "write";
  };
  </code></pre>
  
  <p>This is not ideal, as that it grants all applets permissions to read write all files.  Naturally I would prefer to isolate to the particular code base.  However I could not find a "grant codeBase" syntax that works.</p>
  
  <p>I have tried:</p>
  
  <pre><code>grant codeBase "file:/C:/Files/FileIOApplet/-" {
    permission java.io.FilePermission "&lt;&lt;ALL FILES&gt;&gt;", "read";
    permission java.io.FilePermission "&lt;&lt;ALL FILES&gt;&gt;", "write";
  };
  
  grant codeBase "file:///-" {
    permission java.io.FilePermission "&lt;&lt;ALL FILES&gt;&gt;", "read";
    permission java.io.FilePermission "&lt;&lt;ALL FILES&gt;&gt;", "write";
  };
  
  grant codeBase  "file:${user.home}/-"
  {
    permission java.io.FilePermission "&lt;&lt;ALL FILES&gt;&gt;", "read";
    permission java.io.FilePermission "&lt;&lt;ALL FILES&gt;&gt;", "write";
  };
  </code></pre>
  
  <p>This is running using this configuration:</p>
  
  <ul>
  <li>Firefox 3.6.10</li>
  <li>Java  1.6 update 25</li>
  <li>Windows 7 64 bit</li>
  </ul>
  
  <p>Where I am I going wrong in setting up this .java.policy file?</p>
  
  <p>I am pretty rusty to the Java world, especially working with applets - so your expertise is appreciated!</p>