Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with using signed Applet with policy File
    text
    copied!<p>i have a problem with the .java.policy entries for my applet.</p> <p>I would try to create folders and files with an applet. I had already signed my jar and added in the ${user.home}/.java.policy-file the following lines:</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>with this added lines, my applet works great, <strong>but this is not a good style, because every jar at any places becomes the file permissions too</strong>.</p> <p>At the oracle pages are examples to set the codeBase to the specified applet.jar and set the signedBy (the alias wich the jar-file is signed) to grand permissions.</p> <p>I have tried this many times, but it doesn't work.</p> <p>The code i have tried:</p> <pre><code>grant codeBase "http://www.wkmovies.de/appletDemo/-" { 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>or</p> <pre><code>grant signedBy "AKlettke" { 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>I have uploaded this example to: <a href="http://www.wkmovies.de/appletDemo/index.html" rel="nofollow">www.wkmovies.de/appletDemo/index.html</a></p> <p><strong>How can i set up the policy file, that my applet will work?</strong></p> <hr> <p>Here my code snips: HTML:</p> <pre><code>&lt;a href="javascript:document.applet1.createFolder();"&gt; Create Folder at C:\\Temp &lt;/a&gt; &lt;applet name="applet1" id="applet1" width="0" height="0" alt="" archive="applets/Demo.jar,applets/lib/commons-lang-2.4.jar" code="demo.FolderCreator.class"&gt; &lt;/applet&gt; </code></pre> <p>FolderCreator class:</p> <pre><code>try { File f = new File("C:\\temp"); f.mkdir(); JOptionPane.showMessageDialog(null, "folder created", "successfull", JOptionPane.INFORMATION_MESSAGE); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.getMessage(), e.getClass().getName(), JOptionPane.ERROR_MESSAGE); } </code></pre> <p>(JDK1.6.0_23, Firefox 3.0.19, WinXP 32bit)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload