Skip to main content

Can my application know the location of the jnlp file that launched it?

8 replies [Last post]
anilp1
Offline
Joined: 2006-03-20
Points: 0

Can my application know the location of the jnlp file that launched it?
Or, is there some workaround that will allow relative references?
I have a folder on the client desktop that contains some data files and the jnlp file.
The folder is not on the webserver, though the jars were originally downloaded from there.
When the user clicks on it, it launches the application, and passes in the tag, the relative path of the datafile. for example, ../mydata1.txt.
Passing in the relative path is good because (like html), the folder can be moved to another location or emailed, and the application still work.
Does anyone know how to do this?
thanks,
Anil Philip
goodnewsforyou A T yahoo D O T com
P.S. my application is digitally signed so I am not using the basic and other jnlp services.

I want the location of the jnlp file. This will allow the application to access the data files in the folder that contains it. This will likely be on the client.
If html provides for relative urls, why cant jnlp?!!!
This is rather urgent for me so any help appreciated.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
anilp1
Offline
Joined: 2006-03-20
Points: 0

The solution was simple and straightforward!
I realized that the jnlp is in folder System.getProperty("user.dir") because that's where the user just clicked!
So now the argument can be relative and resolved in the application with these two pieces base+arg.
thanks,
Anil Philip
for good news go to http://members.tripod.com/~goodnewsforyou/

anilp1
Offline
Joined: 2006-03-20
Points: 0

[b]I celebrated too soon :([/b]
The user is not likely to directly click on the jnlp file. He will click on a hyperlink in an html page. So the "user.dir" will [u][b]NOT[/b][/u] contain the location of the jnlp file.
Really, the Java team should be listening to this. This is an important opportunity - if you allow jnlp files to behave like html files do. All it would take is allow javaws to take a second argument - the location of the jnlp file whose url that the user clicked.
After all, in Internet Explorer, when I mouseover the hyperlink in the HTML page, on the bar at the bottom of the window, I can see the correct resolved url location of the jnlp file.
thanks,
Anil Philip

neilweber
Offline
Joined: 2003-06-25
Points: 0

I use BasicService.getCodeBase(). This service is always available regardless of the security settings or whether the jars are signed.

Neil

anilp1
Offline
Joined: 2006-03-20
Points: 0

> I use BasicService.getCodeBase(). This service is
> always available regardless of the security settings
> or whether the jars are signed.
>
> Neil

Thanks for replying.
How will that help?
As per my understanding, getCodeBase() will simply return the URL of the jar on the [b][i]server[/i][/b].

I want the [b][u]location of the jnlp file[/u][/b]. This will allow the application to access the data files in the folder that contains it. This will likely be on the [u][b]client[/b][/u].
If html provides for relative urls, why cant jnlp?!!!
This is rather urgent for me so any help appreciated.

neilweber
Offline
Joined: 2003-06-25
Points: 0

Oh, I thought you wanted to know the location of the JNLP on the server.

I don't know how to get the location of the JNLP. It's probably stored in the browsers cache since it is the browser that downloads the JNLP and then invokes Java WebStart.

I don't know what you're trying to do, but I can't think of why you'd want to know where the JNLP is stored locally. If you're trying to get at resources (icons, property files, etc) that you're providing, the resources should go into one of your jars and then you'd use the standard Java resource location mechanisms (e.g. Thread.currentThread().getContextClassLoader().getResource(imageName)). That's what I'm doing and the code runs fine standalone or via Java Webstart.

Neil

anilp1
Offline
Joined: 2006-03-20
Points: 0

Sorry, but yet again it looks like [u]you have not read the question[/u]. :)
-
Anil

> Oh, I thought you wanted to know the location of the
> JNLP on the server.
>
> I don't know how to get the location of the JNLP.
> It's probably stored in the browsers cache since it
> t is the browser that downloads the JNLP and then
> invokes Java WebStart.
>
> I don't know what you're trying to do, but I can't
> think of why you'd want to know where the JNLP is
> stored locally. If you're trying to get at resources
> (icons, property files, etc) that you're providing,
> the resources should go into one of your jars and
> then you'd use the standard Java resource location
> mechanisms (e.g.
> Thread.currentThread().getContextClassLoader().getReso
> urce(imageName)). That's what I'm doing and the code
> runs fine standalone or via Java Webstart.
>
> Neil

alski
Offline
Joined: 2005-04-05
Points: 0

We do it by having the JNLP servlet patch the location in as an to the application that is the codebase.

anilp1
Offline
Joined: 2006-03-20
Points: 0

> We do it by having the JNLP servlet patch the
> location in as an to the application that
> is the codebase.

That is not useful here!
If webstart allows the application to run offline, then each time the jnlp file is moved on the client's local desktop, will the server have to update it each time?

[i][b]Why doesnt the application have access to the location of the jnlp file? that way, relative location references would be possible.[/b][/i]

thanks,
Anil