Solved

Java Web Start & JNLP

Posted on 2001-07-19
12
319 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now