1

All: I am facing a problem here, my app is composed by some jar files and some other files, they are all located in one directory. I am planning to implement an auto-update feature. When the app know there is a new version on the server, it will download a zip file to temp directory. After downloading, it will ask customer if he'd like to install it. If yes, my app will exit and I need to unzip the zip file and overwrite all files in the original directory. Now I am wondering:

How can I unzip the file and overwrite the directory? Create a script (which means I need to write bat for Windows and shell for other platforms)? Create a java class to do it?

How can I start this script/ java class after exiting?

Once the job is done, how do I delete the installer? Keep it in temp directory and check it out when new version app start?


From later comments:

I know JWS is a good choice, but for reason "my boss denied", I can't use it.

1
  • 2
    Java Web Start is the standard Java solution to the problem you have posed. You're unlikely to get a different answer unless you give a technical restriction as to why your boss denies it. Commented May 5, 2012 at 0:46

2 Answers 2

3

There could be several approaches. Since you say the application is cross-platform, it would be wise to use Java for update.

You can create a small jar file which will handle the update process. It could be part of the initial application (with the assumption it won't be updated) or it could be part of the update package (then you can update it as well).

So your application downloads zip, unpacks it to a temporary directory and starts the updater, then it exits. The updater copies new jars over the old ones.


Yet it's better to not reinvent the wheel. Consider using JWS: it provides more features and requires less effort to implement. There must be good reasons to deny JWS. You should persuade your boss by explaining the benefits of using JWS.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you all. Done with it. I wrote a class to do the installation. I will be forked by a shutdown hook in the app. Of course JWS is great, I hope I can do it with JWS's way next time.
3

Since the app. has a GUI (judging by the Swing tag), deploy it using Java Web Start:

Java Web Start (JWS) is the Oracle Corporation technology used to launch rich client (Swing, AWT, SWT) desktop applications directly from a network or internet link. It offers 'one click' installation for platforms that support Java.

JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..

3 Comments

Thanks for the advice, I know JWS is a good choice, but, for some reason, I can't use it.
Actually, the reason is pretty simple, my boss denied. 8-)
Now is the time to ask your boss - "Why?" since the possible alternatives will depend on the answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.