Java - How to get permission in Java Web Start
Solution 1
You need to sign your JNLP file and configure the <security>
element, as discussed here.
Solution 2
Add the following to your JNLP:
<security>
<all-permissions/>
</security>
This will pop a dialogue asking the user the give the necessary permission to your app.
Solution 3
If you want access to the file system you need to change your JNLP file to include:
<security><all-permissions/></security>
This requires you to also sign your jar files.
Another option is to package the file inside the jar as a resource and you don't have to do all that.
Kurt
Updated on July 09, 2022Comments
-
Kurt almost 2 years
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.
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
-
Kurt over 13 yearsHi Trojanfoe thansk for your help - again! added the <security> element as advised by adnans and Trashgod but still not working how do I sign my JNLP?
-
trojanfoe over 13 years@Kurt: My pleasure. Check this out: download.oracle.com/javase/tutorial/deployment/jar/…
-
Kurt over 13 yearsThanks Trojanfoe will look at this. Man you really know your stuff.