简体   繁体   中英

Simple Question regarding Java Web Start Applications

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/" href="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.

默认情况下,这些应用程序在沙盒中运行,以保护用户免受恶意代码的侵害,因此我将拒绝。

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM