Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Lionel - 26 Nov 2007 10:31 GMT
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.
Daniel Dyer - 26 Nov 2007 10:39 GMT
> I'm wondering if it is possible to find out the codebase value from your  
> java application when using JWS?
[quoted text clipped - 14 lines]
>
> 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.

Signature

Daniel Dyer
http://www.uncommons.org

Lionel - 26 Nov 2007 10:44 GMT
> There is an example servlet (called "jnlpservlet") that comes with the
> JDK.  It serves up JNLP files and replaces certain tokens in them
[quoted text clipped - 5 lines]
> 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.
Andrew Thompson - 26 Nov 2007 11:49 GMT
>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.

Signature

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

Lionel - 26 Nov 2007 11:57 GMT
>> I'm wondering if it is possible to find out the codebase value from your
>> java application when using JWS?
[quoted text clipped - 24 lines]
> 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.
Andrew Thompson - 26 Nov 2007 12:37 GMT
>>> I'm wondering if it is possible to find out the codebase value from your
>>> java application when using JWS?
...
>> 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, ..

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.ht
ml#getCodeBase

()>
e.g.
<http://www.physci.org/jws/#bs>

Signature

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

Lionel van den Berg - 27 Nov 2007 09:27 GMT
>>>> I'm wondering if it is possible to find out the codebase value from your
>>>> java application when using JWS?
[quoted text clipped - 17 lines]
> e.g.
> <http://www.physci.org/jws/#bs>

Now that is just awsomeness! :). Thanks, I'm smacking my head for not
typing javax.jnlp in Netbeans and seeing what came up!

Thanks

Lionel.
Andrew Thompson - 27 Nov 2007 10:50 GMT
>>>>> I'm wondering if it is possible to find out the codebase value from your
>>>>> java application when using JWS?

(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!

Signature

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

Lionel - 27 Nov 2007 11:37 GMT
> (cautiously) I am familiar with that feeling.  You 'get used to'
> the same old search and research tools producing results, but
[quoted text clipped - 5 lines]
>
> 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.
Andrew Thompson - 27 Nov 2007 12:55 GMT
...
>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).

Signature

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

Lionel - 29 Nov 2007 10:38 GMT
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 :(.
Andrew Thompson - 29 Nov 2007 21:38 GMT
...
>There isn't a solution to this is there? This sort of makes it a java
>web start only app.

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

Signature

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

Lionel van den Berg - 30 Nov 2007 08:31 GMT
> ..
>> There isn't a solution to this is there? This sort of makes it a java
>> web start only app.
>
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.