jnlp 尝试使用 pdf 文件调用 showDocument 时权限被拒绝
我需要一些有关 jnlp 应用程序中的 showDocument 的帮助。 我试图在浏览器的另一个选项卡中显示 pdf 文件,但 java 插件拒绝了。
我的 JNLP 文件有一个
<security>
<all-permissions/>
</security>
,我的代码是:
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;
}
});
但我收到异常
java.lang.SecurityException: showDocument url permission denied
如果我尝试执行 showDocument(google.com, _blank) 有效...但当我尝试显示任何文件时,它不起作用。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AppletContext
的showDocument(URL)
方法从未用于从本地文件系统启动文件(即使指定为file
协议 URL )。至少有两种选择:
Desktop.browse(URI)
可以被调用。BasicService
提供showDocument(URL)
方法。The
showDocument(URL)
method ofAppletContext
was never intended for launching files off the local file-system (even when specified as afile
protocol URL).There are at least two alternatives:
Desktop.browse(URI)
can be invoked.BasicService
of the JNLP API offers theshowDocument(URL)
method.