0

I made an java application that need to access files, when i'm try to use it i get an error saying that i don't have the right permission. How can I get him to ask permission before running?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433

2 Answers2

1

There are two ways to go about this:

1. Trusted applet

Code in a Jar can be digitally signed by the developer. Once it reaches the user, they will be prompted as to whether they want to trust the code. If they click OK, the code will be able to do (almost) anything that a normal app. can do.

The user is prompted once, at start-up, to allow the applet to do 'anything'. This is scary to most people.

2. Plugin 2 architecture JRE

Sun's 1.6.0_10 JRE introduced the Plug-In 2 ('Next Generation') architecture that allows embedded applets to be deployed using Java Web Start. Apps. deployed using JWS get access to the JNLP API, which includes the file services. The file services allow untrusted apps. to access the file system, after prompting the user. Here is a demo. of the file services.

Chase the links in the applet info. page for more details.

The applet arrives with no prompt. When the applet attempts to use the file services, the user will be prompted that the applet is trying to access the local file system, and asked if they will allow it. Since this prompt can be made to happen the moment after the user selects the 'Export Data' menu item, it is easy to understand and a lot less scary.

appdata

Don't write information to appdata, at least not for the users of OS X or *nix. Instead put the data in a sub-directory of user.home.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
-1

Java applets run in a secure environment browser. Therefore, always ask permission

Sergej Raishin
  • 535
  • 4
  • 7
  • I need to write into a file in appdata, it don't let me to do so because i don't have right permission. –  Mar 02 '12 at 19:07
  • For appdata: http://pastebin.com/W8dnXWkQ It was too large to post here, but I use this for applets / jars jframes and it works. –  Mar 02 '12 at 19:19