Java - 如何在 Java Web Start 中获得许可 [英] Java - How to get permission in Java Web Start
问题描述
设法为我的 Java 应用程序创建了 jar 和 .jnlp 文件,但在运行时遇到了问题.使用 Java Web Start 启动没问题,但我想我需要做点什么像往常一样,当我运行它时,它不会要求获得访问 HD 以进行文件 I/O 的权限.
Hi managed to create the jar and .jnlp files for my Java application but running into trouble when it runs. Launches okay with Java Web Start but I think I need to do something extra as normally when I run it it doesn't ask for permission to access the HD for file I/O.
希望得到一些帮助和建议,以了解如何获得许可权,即我必须做的事情是我对所有课程都不确定的事情.错误我在 Java Web Start 中收到的消息如下.
Would appreciate some help and advise to know what to do to get the permission rights i.e. what do I have to do is it something I have to do to all my classes not sure. The error message I get in Java Web Start is as below.
Exception in thread "AWT-EventQueue-0" java.security.AccessControlException:
access denied (java.io.FilePermission StockDatabase;Stocks.dat read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.File.exists(Unknown Source)
at StockCodeDatabase.<init>(OptraderSA.java:782)
at OptraderSA.actionPerformed(OptraderSA.java:136)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unkno
推荐答案
您需要对 JNLP 文件进行签名并配置 <security>
元素,如这里.
You need to sign your JNLP file and configure the <security>
element, as discussed here.
这篇关于Java - 如何在 Java Web Start 中获得许可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!