Can a Java application launched using Java Web Start perform read/write operations on user's hard drive. I know that this is not the case with java script embedded in a web page. Basically what I am asking are there any such restrictions with a java application invoked using a web browser?
Kurt
I am having trouble using the {} to insert code
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="file:///c:/Users/OPTRADER/" hre开发者_JS百科f="trader.jnlp">
<information>
<title>Optrader</title>
<vendor>DS Software</vendor>
<description>Optrader JNLP Demo </description>
<offline-allowed/>
</information>
<resources>
<jar href="Optrader.jar"/>
<j2se version="1.6+" href="java.sun.com/products/autodl/j2se"/>
</resources>
<application-desc main-class="Optrader"/>
</jnlp>
{
Optrader
DS Software
Optrader JNLP Demo
Yes they can. In the JNLP file for the application you can specify if the application has All permissions. It can operate just like a normal Java desktop application. The difference is that you need to sign the jars if you are going to grant the permission. However, you have the ability to sign them yourself.
By default these applications run in a Sandbox to protect users from malicous code, so I'd say "no".
For a sand-boxed local file access with Webstart (and with JNLP-applets to, from Java 6, update 10, when the new plugin came out), use the services in the javax.jnlp package (linked from the Webstart documentation page.
In this case, a FileOpenService and/or FileSaveService lets the user confirm the action and select a file in a filechooser, and you then get a FileContents object, which you can then read from or write to.
You don't need special permissions for that, not even sign your code (but I think if you do, the confirmation dialog looks less intimidating, as it contains the information who wants this).
If you want to see how it looks like from user perspective, use our Applet here and select custom picture.
From your comments it seems that your problem is something completely different than in your original question.
To start your Webstart-application, save the XML file you have there under the name trader.jnlp
in your directory c:/Users/OPTRADER/
, and then double-click on it. If webstart is configured right and the jar file is also in the right place, it now should start your program.
If you get some error message saying that Windows does not now what to do with your file, then you should reinstall Java webstart (or your JRE/JDK).
If you get some error message from Webstart, add this message to your question (there is an edit link below it).
If your program runs and you have some other problem, describe the problem (also in your question).
精彩评论