Solved

Java Web Start & JNLP

Posted on 2001-07-19
12
326 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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.

724 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