For Programmers: Free Programming Magazines  


Home > Archive > Java Help > February 2006 > Auto Updating an App









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Auto Updating an App
Allan Bruce

2006-02-28, 7:58 am

I have my application communicate with a server to determine if there is a
newer version available. I have a native windows C++ version and a Java
version for other platforms. As far as the Java side goes, is there an easy
way to update the Jar file? i.e. my program a.jar will have a new version,
so it should download http://somewhere.com/a.jar and replace itself?

In C++ I execute another small program which grabs the file from the web,
replaces the old one and launches the new one. Is this what I will have to
do in Java? If so, how do I launch another java program? It will be
guaranteed to be in the same directory as the program a.jar. Also is there
an easy way to get a binary file from an http server, or do I have to do
that myself as I did with the C++ version?

Thanks
Allan


VisionSet

2006-02-28, 7:58 am


"Allan Bruce" <amb@abc.net> wrote in message
news:D5mdnb6VqeUnuZnZRVnyhg@pipex.net...

> As far as the Java side goes, is there an easy
> way to update the Jar file? i.e. my program a.jar will have a new

version,
> so it should download http://somewhere.com/a.jar and replace itself?
>


With RMI you can update existing classes or load new classes across a
network at runtime. Or you can use JavaWebStart for more orthodox version
updates. Basically it is very easy if you can guarantee a network
connection, otherwise you need some fallback.

--
Mike W


Roedy Green

2006-02-28, 7:58 am

On Tue, 28 Feb 2006 10:23:52 -0000, "Allan Bruce" <amb@abc.net> wrote,
quoted or indirectly quoted someone who said :

>As far as the Java side goes, is there an easy
>way to update the Jar file? i.e. my program a.jar will have a new version,
>so it should download http://somewhere.com/a.jar and replace itself?


Look into JAWS. I can be used to keep jars up to date, and to run an
installer class you write when a new one arrives. So you could use it
to keep a C++ program up to date as well.

See http://mindprod.com/jgloss/javawebstart.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Roedy Green

2006-02-28, 7:58 am

On Tue, 28 Feb 2006 10:23:52 -0000, "Allan Bruce" <amb@abc.net> wrote,
quoted or indirectly quoted someone who said :

>In C++ I execute another small program which grabs the file from the web,
>replaces the old one and launches the new one. Is this what I will have to
>do in Java?


There many ways you can handle it. See
http://mindprod.com/jgloss/installer.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Roedy Green

2006-02-28, 7:58 am

On Tue, 28 Feb 2006 10:23:52 -0000, "Allan Bruce" <amb@abc.net> wrote,
quoted or indirectly quoted someone who said :

> If so, how do I launch another java program?

You have at least two choices. IF you want to launch it quickly in
the same JVM you just call its main method. If you want to launch an
independent JVM you use exec. See http://mindprod.com/jgloss/exec.html


>It will be
>guaranteed to be in the same directory as the program a.jar.


For finding things you can put the location on the command line, in a
system property, in the registry via the Preferences class, or you can
use CWD relative addressing.

> Also is there
>an easy way to get a binary file from an http server, or do I have to do
>that myself as I did with the C++ version?


Use JAWS to automatically deliver a jar for you. It it up to you to
write a class to unpack it when it arrives. Alternatively you could
use the FileTransfer.download method to get it direct from the server.
See http://mindprod.com/products1.html#FILETRANSFER

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Oliver Wong

2006-02-28, 7:04 pm


"Roedy Green" <my_email_is_posted_on_my_website@munged.invalid> wrote in
message news:70h802t6oug9go5o742ubs6vuptdtbk2m6@
4ax.com...
> On Tue, 28 Feb 2006 10:23:52 -0000, "Allan Bruce" <amb@abc.net> wrote,
> quoted or indirectly quoted someone who said :
>
> You have at least two choices. IF you want to launch it quickly in
> the same JVM you just call its main method.


You'd probably want to surround the call to the main method with "catch
Throwable", as you don't want any exceptions from the other program killing
your program as well.

Anyone know of a way of overriding System.exit() so that if the
sub-program calls it, control returns to your program?

- Oliver

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com