Adam
Adam

Reputation: 83

File manipulation won't work in Java Web Start

I built this program that works with files. Since I made it for a friend, I made it into a Java Web Start app, complete with a JNLP file.

When I launch the app through an ANT (netbeans) without the JNLP, it works just fine. But when launched through the JNLP (even through netbeans), the button that is supposed to perform the required actions instead does nothing (it just stays in "clicked" mode until you hover away from it).

I spent hours trying to figure out the problem, but no luck.

Here is the problematic method:

public void copy(String path1, String path2) throws IOException {

    File inputWorkbook = new File(inputFile);
    Path in = Paths.get(path1);
    Path out = Paths.get(path2);



    Workbook w;
    try {
        w = Workbook.getWorkbook(inputWorkbook);
    .
    .
    .

If I don't attempt to do anything with the inputWorkbook file, everything works ok. As soon as I attempt ANY sort of method on it (such as w = Workbook.getWorkbook(inputWorkbook), or even inputWorkbook.exsists();) , the problem occurs. It won't even throw an exception, it just does nothing... Again, the problem only occurs when the program is launched through the JNLP file.

I hope I managed to explain the problem... I'm new to programming.

Thank you!!!

Adam

Upvotes: 0

Views: 142

Answers (1)

JB Nizet
JB Nizet

Reputation: 691625

Webstart applications run in a security sandbox which prevents the to access the file system. You need to digitally sign your har to gain access to the file system, or use the file open api. See http://download.oracle.com/javase/6/docs/technotes/guides/javaws/developersguide/faq.html#302 and http://download.oracle.com/javase/6/docs/technotes/guides/javaws/developersguide/examples.html#FileOpenService for more information.

Upvotes: 2

Related Questions