• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how do make a java application update itself

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a java application that is distributed to the public. When the user starts the application it checks my web site for the latest version and if there is a newer version then the app downloads the JARfiles and places them in the appropriate locations. BTW: this is a cross-platform app that runs on Windows, Mac OSX and Linux. All this works so my question is this. Once the download of the new JARs is complete, how to I tell my application to stop itself and then relaunch automatically.

Thanks in advance for any ideas and assistance.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Call Runtime.exec() to run a second copy of the application -- which would use the newly-downloaded jars -- and then call System.exit() to stop.
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Harry.

The advice on this issue I hear most is switch to Java Web Start. That way users always download the latest version.
 
Harry Harding
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul, Thanks for the tip. I'm going to try this today and let you know how I make out. I have command line parameter I need to pass to the JVM but it looks like Runtime.exec() will allow that. I just need to figure out the syntax. Thanks again.

Rob, Thanks for the tip but I don't know if Java Web Start will help. I don't know enough about it but though my app is downloadable from the web it isn't a web app. It is a desktop app that don't require an internet connection to run. If an internet connection is available it does check for updates but if the connection isn't there it bypasses the check and runs as a local app. Does that fit with the Java Web Start scheme? The app lives on the user's local machine.

Again, thanks to both of you for the feedback.

Harry
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try starting here. To be honest I haven't used it before so I can't tell you if it caches the versions so you can run them locally.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Harry Harding wrote:I don't know enough about it but though my app is downloadable from the web it isn't a web app. It is a desktop app that don't require an internet connection to run. If an internet connection is available it does check for updates but if the connection isn't there it bypasses the check and runs as a local app. Does that fit with the Java Web Start scheme? The app lives on the user's local machine.


Yes, that fits with the Java Web Start scheme. A Java Web Start application is an app that's usually downloaded and installed from the web, but once it's installed it runs just like any other Java program on a user's local machine. Java Web Start provides a mechanism to do exactly that what you describe: check if there's a newer version on the web, if no then run the currently installed version, otherwise download the new version, install it and run that.

Using Java Web Start does not make your application a web app.
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You seem to have the requirement that the application should check every 25 seconds (or some period) to see if there's a new version available, and to update itself on the fly if there is. Is that correct?

Java Web Start doesn't do that. All it does is to check when the application is started for new versions, and download the new version before starting the application if there is one. Generally that's sufficient for most applications, and it works fine if that's what you need.
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote:Try starting here. To be honest I haven't used it before so I can't tell you if it caches the versions so you can run them locally.


Yes, you can run Web Start applications on your machine without access to the host they came from. I believe there's an option to prevent that from happening, but it's a normal operating mode for Web Start.
 
Harry Harding
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all for the advice. Paul, I'm sorry if I was not clear. No I do not have any specific update frequency constraint (25 secs), checking at the start of the app is fine and actually preferred so it sounds like Java Web Start is the answer to my problem. Now all I have to do it learn how to use it. Thanks for the link Rob, I'm going to check this out before I bother you all again.

Also, BTW: Thanks for making a newcomer feel welcome. I think I may have found a new home.
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
reply
    Bookmark Topic Watch Topic
  • New Topic