[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Java Web Start & JNLP

Posted on 2001-07-19
12
Medium Priority
?
333 Views
Last Modified: 2012-06-27
Hi everybody!

     I'm using an application with Java Web Start and, of course, I've created a JNLP file.
The problem is that my application use an external text file, and I don't know how to "tell" Java Web Start to download this file too, when I'm starting the application.

I guess the problem is in JNLP's configuration. I don't know how to configure this JNLP file to specify that I need an external resource for my application.

Can anyone help me ?

Thanx a lot.
Sam
0
Comment
Question by:asimion
12 Comments
 
LVL 9

Expert Comment

by:Ovi
ID: 6298102
Why don't you put all files (the app and the txt) in a global .jar file ?
0
 

Expert Comment

by:LG_Goundalkar
ID: 6298105
Hi..
Try this..

import javax.jnlp.*;
    ...

    DownloadService ds;

    try {
        ds = (DownloadService)ServiceManager.lookup("javax.jnlp.DownloadService");
    } catch (UnavailableServiceException e) {
        ds = null;
    }

    if (ds != null) {

        try {
            // determine if a particular resource is cached
            URL url =
                    new URL("http://localhost\file location
            boolean cached = ds.isResourceCached(url, "1.0");
            // remove the resource from the cache
            if (cached) {
                ds.removeResource(url, "1.0");
            }
            // reload the resource into the cache
            DownloadServiceListener dsl = ds.getDefaultProgressWindow();
            ds.loadResource(url, "1.0", dsl);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

LGG

0
 

Author Comment

by:asimion
ID: 6298532
Hi LGG,

     I've tried your code but it doesn't seem to download the file. I don't receive any error but I don't get the file either. How can I know if the download was succesfully and how can I acces the downloade file ?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 6300538
If you put the file in your jar then you can simply read it using:

InputStream in = ClassLoader.getSystemResourceAsStream("filename.txt");

// Read your file from input stream


0
 

Author Comment

by:asimion
ID: 6301011
I don't want to use the file inside the jar !
I now this way it's working, because the file will be downloaded by JavaWebStart. But I need the file outside the jar because will be modified very often, and I don't want to modify the whole jar every time.
0
 
LVL 92

Expert Comment

by:objects
ID: 6301021
Then you'll need to make it available somewhere for download, as far as I know Web Start doesn't support additional resources.
Will check for u.
0
 

Author Comment

by:asimion
ID: 6301035
The txt file is in the same directory with the jar file and the JNLP file on the server.

If I try to download the file like this :

http://servername/filename.txt with any browser, it's working!

So, that mean it's available for download...., isn't it ?
0
 
LVL 92

Expert Comment

by:objects
ID: 6301042
JNLP only supports specifying jars, images, and other jnlp's. So you'll need to jar your external text file for jnlp to grab it.

Something like this:

<resources>
  <jar href="http://abc.com/text.jar"/>
</resources>

Then use the standard getResource methods in your code to access your data.

If you need more info have a look at the JNLP spec.

0
 
LVL 92

Expert Comment

by:objects
ID: 6301046
That does mean its available for download.
0
 
LVL 1

Expert Comment

by:sey7
ID: 6305195
Maybe you can ask Sey again to solve the problem.


Best Regards,   :)
0
 
LVL 5

Expert Comment

by:vemul
ID: 7669629
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- To be PAQ'ed and points NOT refunded
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

vemul
Cleanup Volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7714630
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month19 days, 8 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question