I need some help with this showDocument in my jnlp aplication.
I trying to show a pdf file in another tab from browser, but the java plugin denied.
My JNLP file has a
<security>
<all-permissions/>
</security>
and my code is:
AccessController.doPrivileged(new PrivilegedAction()
{
@Override
public Object run()
{
try
{
applet.getAppletContext().showDocument(new URL("file:///C:/Contrato.PDF"), "_blank");
}
catch(Exception e)
{
e.printStackTrace();
showException("Erro ao exibir arquivo:" + e.getMessage());
}
return null;
}
});
but I receive the exception
java.lang.SecurityException: showDocument url permission denied
If I try to do showDocument(google.com, _blank) that works…but when I try to show any file, it does not work.
The
showDocument(URL)method ofAppletContextwas never intended for launching files off the local file-system (even when specified as afileprotocol URL).There are at least two alternatives:
Desktop.browse(URI)can be invoked.BasicServiceof the JNLP API offers theshowDocument(URL)method.