Is it possible to find out codebase value from JWS app?

L

Lionel

I'm wondering if it is possible to find out the codebase value from your
java application when using JWS?

If not, what is the best approach for the following problem.

I want to be able to look up a .exe, and download it from the install
server of the JWS app only on request by the user.

I am currently downloading the file but only by knowing the website that
the files are hostted on, I want the files to be able to be unzipped
anywhere, a small app will guide the user through configuring the
codebase in the JNLP file. I guess I could always write a file with the
information in it at configuration time and then add that to a jar, but
it's a bit of stuffing around.

Thanks

Lionel.
 
D

Daniel Dyer

I'm wondering if it is possible to find out the codebase value from your
java application when using JWS?

If not, what is the best approach for the following problem.

I want to be able to look up a .exe, and download it from the install
server of the JWS app only on request by the user.

I am currently downloading the file but only by knowing the website that
the files are hostted on, I want the files to be able to be unzipped
anywhere, a small app will guide the user through configuring the
codebase in the JNLP file. I guess I could always write a file with the
information in it at configuration time and then add that to a jar, but
it's a bit of stuffing around.

Thanks

Lionel.

There is an example servlet (called "jnlpservlet") that comes with the
JDK. It serves up JNLP files and replaces certain tokens in them
($$codebase, $$name and $$context) with the appropriate values for the
current environment.

Of course, this requires that you are using a servlet container on the
server. If this is a web-hosting account rather than your own server and
you don't have servlet hosting but you do have PHP, you could probably do
something similar (generate a JNLP file from PHP).

Dan.
 
L

Lionel

Daniel said:
There is an example servlet (called "jnlpservlet") that comes with the
JDK. It serves up JNLP files and replaces certain tokens in them
($$codebase, $$name and $$context) with the appropriate values for the
current environment.

Of course, this requires that you are using a servlet container on the
server. If this is a web-hosting account rather than your own server
and you don't have servlet hosting but you do have PHP, you could
probably do something similar (generate a JNLP file from PHP).

It's a web-hosting account so the latter suggestion will be worth
investigating. I don't know PHP so this doesn't make immediate sense to
me, but it's a good start for google :).

Lionel.
 
A

Andrew Thompson

Lionel said:
I'm wondering if it is possible to find out the codebase value from your
java application when using JWS?

Don't. Many apps. broke in Java 6 because the developers
had used hackich code to discover the codebase. The
end-user, or their sys-admin, (or sun,) can change the
cache location at will, and it is not our business to know
where it is.
If not, what is the best approach for the following problem.

I want to be able to look up a .exe, and download it from the install
server of the JWS app only on request by the user.

Manually download the .exe to a directory either
- specified by the user (for example using a
JFileChooser specifying directories only.)
- or if it is not of direct use to the user (to know where
it is) downlaod it to a sub-directory of user.home
(based on package name).

If it is necessary to store the path for future reference
(what is thing .exe? an installer?) you might look to
the JNLP API's PersistenceService. E.G.
<http://www.physci.org/jws/#ps>

I cannot see that changing the codebase, as you and
Daniel were discussing, could help with this problem.
 
L

Lionel

Andrew said:
Don't. Many apps. broke in Java 6 because the developers
had used hackich code to discover the codebase. The
end-user, or their sys-admin, (or sun,) can change the
cache location at will, and it is not our business to know
where it is.


Manually download the .exe to a directory either
- specified by the user (for example using a
JFileChooser specifying directories only.)
- or if it is not of direct use to the user (to know where
it is) downlaod it to a sub-directory of user.home
(based on package name).

If it is necessary to store the path for future reference
(what is thing .exe? an installer?) you might look to
the JNLP API's PersistenceService. E.G.
<http://www.physci.org/jws/#ps>

I cannot see that changing the codebase, as you and
Daniel were discussing, could help with this problem.


Not sure if you quite understand my problem, or I don't understand your
response, although I believe I do as the above are problems I'm already
aware of. Put it this way.

Server 1 located at www.server1.com contains in a web accessable directory:

app.jar
app.jnlp
app.html
someexe.exi

server 2 also contains the above files but at www.server2.com. I want a
reliable way of downloading someexe.exe from whatever server is hosting
the files. I only want to download when the user takes a certain action.

Thanks

Lionel.
 
A

Andrew Thompson

Lionel said:
Not sure if you quite understand my problem, or I don't understand your
response, ..

It was definitely me not understanding you. (silly grin)
..although I believe I do as the above are problems I'm already
aware of. Put it this way. ...
server 2 also contains the above files but at www.server2.com. I want a
reliable way of downloading someexe.exe from whatever server is hosting
the files.

<http://java.sun.com/javase/6/docs/jre/api/javaws/jnlp/javax/jnlp/BasicService.html#getCodeBase
()>
e.g.
<http://www.physci.org/jws/#bs>

--
Andrew Thompson
http://www.physci.org/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200711/1
 
A

Andrew Thompson

Lionel said:
(BasicService)

Now that is just awsomeness! :).

I thought it might be exactly what was needed. (Once the
problem had been explained to me in such small words that
I understood what it was).
...Thanks, I'm smacking my head for not
typing javax.jnlp in Netbeans and seeing what came up!

(cautiously) I am familiar with that feeling. You 'get used to'
the same old search and research tools producing results, but
sometimes they don't.

Oh - and just to clarify for anyone that saw my earlier
bizarre statements. For some reason I read every instance
of 'codebase' as 'cached location on local disk'. Go figure.

Well (tilts head) they're *almost* the same!

--
Andrew Thompson
http://www.physci.org/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200711/1
 
L

Lionel

Andrew said:
(cautiously) I am familiar with that feeling. You 'get used to'
the same old search and research tools producing results, but
sometimes they don't.

Oh - and just to clarify for anyone that saw my earlier
bizarre statements. For some reason I read every instance
of 'codebase' as 'cached location on local disk'. Go figure.

Well (tilts head) they're *almost* the same!

Just to add something to any future searches, you will need to add
javaws.jar to be able to use javax.jnlp. It can be found in
JAVA_HOME/jre/lib.
 
A

Andrew Thompson

Lionel wrote:
...
Just to add something to any future searches, you will need to add
javaws.jar to be able to use javax.jnlp. It can be found in
JAVA_HOME/jre/lib.

Yes. There are a number of tricks to building and testing
JWS based projects that I try to cover in the Ant build file
supplied with each JNLP API example. For example..
<http://www.physci.org/jws/#bs>
Has the link to the '.zip' archive on the far right..
<http://www.physci.org/jws/basicservice.zip>
That should contain an 'out of the box' ready*, build
file, source and JNLP for the example (* for any IDE
that supports Ant).

--
Andrew Thompson
http://www.physci.org/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200711/1
 
L

Lionel

I should probably start a new thread, but on the off-chance you are
still watching.

I've noticed that if I try to run the application not using JWS I get
Exception in thread "main" java.lang.NoClassDefFoundError:
javax/jnlp/UnavailableServiceException

as soon as I try to access the class that uses the jnlp services
regardless of whether or not the particular method I call uses the
service itself. This makes testing a little more difficult.

There isn't a solution to this is there? This sort of makes it a java
web start only app.

My logic suggests this is bad luck :(.
 
L

Lionel van den Berg

Andrew said:
Lionel wrote:
..

The basicservice.zip build file shows how to launch a web start
app. off the local file system. Check the 'launch' task.

Ok, sorry, I'll look at your example in more detail. Previously I just
grabbed the LOC that I wanted and went about my merry way :).

cheers

Lionel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top