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 - 28 Feb 2006 12:29 GMT
> 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 - 28 Feb 2006 12:30 GMT
>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

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Roedy Green - 28 Feb 2006 12:34 GMT
>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

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Roedy Green - 28 Feb 2006 12:43 GMT
> 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

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Oliver Wong - 28 Feb 2006 22:19 GMT
>> 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.
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