File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes java to update jar files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java to update jar files" Watch "java to update jar files" New topic

java to update jar files

Dennis Putnam
Ranch Hand

Joined: Feb 03, 2012
Posts: 230
I am planning to distribute a Java app. However, I am not finding much help on how to manage updates. I cannot simply replace the jar file as there is a resource file that is unique to each installation. Can someone point me to a tutorial that shows how to update a jar which preserves resources in the old file? TIA.
Kemal Sokolovic

Joined: Jun 19, 2010
Posts: 825

Java Web Start?

The quieter you are, the more you are able to hear.
Dennis Putnam
Ranch Hand

Joined: Feb 03, 2012
Posts: 230
Thanks for the reply. Someone suggested that to me off list but in reading through it, I'm not sure it will work. First, the application is OS independent and it appears to me that Web Start requires Active-X which doesn't normally exist on *NIX. Second, there is no web server for this. The updater would need to be standalone and emailable. Perhaps it is not necessary to do anything other than manipulate the various class files using some kind of zip archive interface. In any case I am looking for suggestions how this might be done.
Dennis Putnam
Ranch Hand

Joined: Feb 03, 2012
Posts: 230
After some thought I think I have a solution if I can figure out how to do it. The only thing I really need are the properties from the old version. How do I load properties into a jar file (the new version) from a different jar file (the old version)? TIA.
Joel McNary

Joined: Aug 20, 2001
Posts: 1824

As far as I know, there is no requirement for ActiveX for Java WebStart. The WebStart documentation states that The client machine requires support for the Java Runtime Environment (JRE), version 1.3 or later. Java Web Start is available for Windows 98/NT/2000/ME/XP, the Solaris Operating Environment, and Linux..

But that doesn't really solve your short-term problem. To do what you want, try looking at the package, particularly and You would need to write a separate program to do the updates, treating the Jar files just a plain old Zip files. As long as they are not digitally signed, that should be no problem.

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

And just to clarify, as this hasn't specifically been said yet: You can't update an existing jar file. You're going to have to create a new jar file. In your case this would involve copying all of the entries out of Jar File 1 and copying selected entries out of Jar File 2, into a new jar file.
I agree. Here's the link:
subject: java to update jar files
It's not a secret anymore!