tags:

views:

30

answers:

3

I feel really dumb......

So I am writing a Java app, and if you can help me get this to work you'll be able to see it.

so my jar file is here: http://team2648.com/OTIS2/admin/OmniNode2.8.jar

I would like it to be able to be used as a Java web-start application, i was following the tutorial here: http://download.oracle.com/javase/tutorial/deployment/webstart/deploying.html

so I wrote the following JNLP file as directed:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" 
codebase="http://team2648.com/OTIS2/admin" 
href="test.jnlp">
<information>
    <title>OmniNode Mapper</title>
    <vendor>Techplex Engineer</vendor>
</information>
<resources>
    <!-- Application Resources -->
    <j2se version="1.6+"
      href="http://java.sun.com/products/autodl/j2se"/&gt;
    <jar href="OmniNode2.8.jar" main="true" />

</resources>
<application-desc
     name="OmniNode Mapper"
     main-class="omninode28.Driver"
     width="300"
     height="300">
 </application-desc>
 <update check="background"/>
</jnlp>

But as you'll see if you download the jnlp http://team2648.com/OTIS2/admin/test.jnlp
and run it, We get the following error(On a PC):

access denied (java.io.FilePermission C:\Users\MyUserName\Documents read)

Exception

java.security.AccessControlException: access denied (java.io.FilePermission C:\Users\Techplex Engineer\Documents 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 java.io.Win32FileSystem.canonicalize(Unknown Source)
at java.io.File.getCanonicalPath(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.getPersonal(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
at sun.awt.shell.ShellFolder.get(Unknown Source)
at javax.swing.filechooser.FileSystemView.getDefaultDirectory(Unknown Source)
at javax.swing.JFileChooser.setCurrentDirectory(Unknown Source)
at javax.swing.JFileChooser.(Unknown Source)
at javax.swing.JFileChooser.(Unknown Source)
at omninode28.NodePanel.(NodePanel.java:61)
at omninode28.EditPanel.(EditPanel.java:31)
at omninode28.Driver.main(Driver.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

So those files it points at:

this line: fc = new JFileChooser();

So this leads me to believe that i need to ask the user permission to write to their system.

I am befuddled. Any help would be super, Thanks

Edit... Should I just make users download the Jar directly? pros cons?

A: 

One possibility is, your jar is not signed as mentioned here

Raghuram
+1  A: 

Obviously it would be a bad idea for any website you browsed across to be able to read from your local filesystem. So it isn't allowed directly.

Perhaps the best way around this is to use the FileOpenService. This gives applications a simple interface to a file chooser of some description that can open (read and, unfortunately, write) user selected files without giving direct access to the file system.

Tom Hawtin - tackline
Andrew Thompson
@Andrew Thompson `FileOpenService` also allows the selected files to be modified. There is a (pointless) security warning dialog before the file chooser which used to say just read. Shows how much attention programmers give to security warnings.
Tom Hawtin - tackline
It is unfortunate the 'open' security prompt has changed, since it is now quite inaccurate. Accepting the prompt, even with 'always allow' checked, still results in a prompt when the user goes to save a file. Or at least, that is the behavior I see in the PSCode demo currently. Can you provide code or a demo that acts differently?
Andrew Thompson
+1  A: 

you have to sign the jars and grant permission to the classes by adding this snippet into the jnlp:

<security>
  <all-permissions/>
</security>
virgium03