title: Recover from user clicking "Deny" on "requesting access to your computer" dialog from applet
body: <p>I am running a self signed applet using the deployApplet.js library from Oracle. (Checking the generated html, it is using the <code>applet</code> tag - I am also using a JNLP file per the deployment tutorials from Oracle).</p>
  
  <p>The problem occurs when the user is presented with the dialog requesting permission to access their computer. If they click Allow everything is fine. If they click Deny I get the following exception in the Java Console:</p>
  
  <pre><code>ExitException[ 4]java.lang.RuntimeException: exit(-1)
      at com.sun.javaws.Main.systemExit(Main.java:1316)
      at com.sun.javaws.security.AppPolicy.grantUnrestrictedAccess(AppPolicy.java:283)
      at com.sun.javaws.LaunchDownload.checkSignedResourcesHelper(LaunchDownload.java:1825)
      at com.sun.javaws.LaunchDownload.checkSignedResources(LaunchDownload.java:1508)
      at sun.plugin2.applet.JNLP2Manager.prepareLaunchFile(JNLP2Manager.java:1161)
      at sun.plugin2.applet.JNLP2Manager.loadJarFiles(JNLP2Manager.java:473)
      at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1495)
      at java.lang.Thread.run(Thread.java:680)
  Exception: ExitException[ 4]java.lang.RuntimeException: exit(-1)
  java.lang.NullPointerException
      at sun.plugin.util.ErrorPanel.deniedCertificateFailure(ErrorPanel.java:334)
      at sun.plugin.util.ErrorPanel.&lt;init&gt;(ErrorPanel.java:61)
      at sun.plugin.util.GrayBoxPanel.setError(GrayBoxPanel.java:104)
      at sun.plugin.util.GrayBoxPainter.paintGrayBox(GrayBoxPainter.java:473)
      at sun.plugin.util.GrayBoxPainter$4.run(GrayBoxPainter.java:411)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:682)
      at java.awt.EventQueue.access$000(EventQueue.java:85)
      at java.awt.EventQueue$1.run(EventQueue.java:643)
      at java.awt.EventQueue$1.run(EventQueue.java:641)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:652)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
  </code></pre>
  
  <p>The browser hangs after this and I need to manually kill the Java Applet process or restart the browser. Based on the stack trace and from doing some static initializer debug steps in my applet, it does not appear that any code in my applet gets executed before the exception is thrown.</p>
  
  <p>Is there any way to recover gracefully when the user clicks Deny? Ideally, the applet and JVM would just exit cleanly but I am open to anything that would not leave the browser hanging.</p>
  
  <p>EDIT:</p>
  
  <p>Additional log info before exception is thrown:</p>
  
  <pre><code>security: Showing MacOSXTrustSiteDialog
  security: User permitted app to continue without priviledges
  security: User has denied the privileges to the code
  security: Adding certificate in Deployment denied certificate store
  security: Added certificate in Deployment denied certificate store
  security: We were not granted permission, exiting
  basic: exception: exit(-1).
  Java Plug-in 1.6.0_31
  Using JRE version 1.6.0_31-b04-415-11M3646 Java HotSpot(TM) 64-Bit Server VM
  </code></pre>