wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Java Swing App - How to code - Help - Check for Updates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Java Swing App - How to code - Help - Check for Updates" Watch "Java Swing App - How to code - Help - Check for Updates" New topic
Author

Java Swing App - How to code - Help - Check for Updates

David Garratt
Ranch Hand

Joined: Aug 08, 2003
Posts: 196

I would like to add an option on my application so that it can automatically (and manually) check against a website to see if it's the latest version and offer to download the latest version if it's not.

My best endeavours to google always seem to return results on how to update java itself, rather than an application written in Java.

For this application I don't want to go down the webstart route.

If anyone has done this, or knows of resources/documentation on how this might be done it would be great.

My application is packaged into a windows setup.exe for downloading and installing.

Thanks

Dave
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

David Garratt wrote:I would like to add an option on my application so that it can automatically (and manually) check against a website to see if it's the latest version and offer to download the latest version if it's not....
For this application I don't want to go down the webstart route.


Why do you want to avoid the JWS route? It already has the functionality you are looking for.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

I agree with Maneesh.

The main problem of updating any Java program from the program itself is that the application JAR file may be locked by the operating system (Windows will most certainly do so), which means you cannot overwrite it from the application. You will need to use workarounds partly using operating system specific techniques (close the Java application, only then overwrite the file, relaunch the Java application). This would probably include some form of batch file / shell script (this is the OS specific part) which first sleeps long enough for the Java application to completely close, then overwrites the JAR file, then restarts the Java application.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
David Garratt
Ranch Hand

Joined: Aug 08, 2003
Posts: 196

There are a number of issues with JWS for me at the moment. The necessity for each user of a PC to download the same application. The lack of control over the location where the software is installed. Plus some changes to the application to work with JWS. I do realise that the download/update of JARs will require some thought as JAR's will be in use, but this is not exactly unique to Java, in fact almost every application will have this issue be it jars or dlls.

So, although I thank you for your replies, in this case I would prefer to follow a more non java specific course of action.

I use Install4j for deployment of my application and it does what I want in respect to upgrades. ie. it says a new version is available, downloads it and restarts itself as part of the re-install process.

Thanks again


Dave
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

David Garratt wrote:The lack of control over the location where the software is installed.

And you think you can control this with regular Java programs? Or even with programs written in native code? If so you are a bit naive.
David Garratt
Ranch Hand

Joined: Aug 08, 2003
Posts: 196

OK, trying to be nice here. My application is used by Nestle. Nestle employees have a home directory on a network share. If I deploy via JWS and several people use the same PC, each of them will have to download the full application from the JWS server and it will by default dump it onto their H: (home) drive.

In a factory enviroment when you have multiple shifts its quite normal for 8-10 people to use a single PC. If the application is downloaded and installed as a native type application it can put installed into a nominated local directory (as is their requirement). Also a shortcut can put put on the desktop so that all users can share the same instance of the program.

I'm sure JWS is clever and suitable for some cases, but not in this situtation.

The software will probably be initially installed by MIS personnel so the location will be consistent. Even if it's not, then it will still exist only once.

I take it that your approach would be different than mine, however I've tried to ask a very specific question which justification for doing that particular way.

If you don't know how to help, then feel free not to reply.

Sorry - I've got loads of java based applications that seem to follow the approach I've outlined. Just wanted a hint on how to code it.

Thanks in advance

Dave
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

I think we got each other wrong. I thought you wanted to not use JWS because you wanted to have complete control where the application is installed. That's not what you need; you only need one single installation location instead of one for each user. That makes more sense to me.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java Swing App - How to code - Help - Check for Updates
 
Similar Threads
.net client invoking java code on server
separating input in a dialog
installing MySQL
Programmer Upgrade Exam
how to create Dynamic jnlp files