wood burning stoves 2.0*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java to update jar files" Watch "java to update jar files" New topic
Author

java to update jar files

Dennis Putnam
Ranch Hand

Joined: Feb 03, 2012
Posts: 210
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
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Java Web Start?


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

Joined: Feb 03, 2012
Posts: 210
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: 210
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
Bartender

Joined: Aug 20, 2001
Posts: 1815
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 java.util.zip package, particularly java.util.zip.ZipFile and java.util.zip.ZipEntry. 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
Bartender

Joined: Oct 14, 2005
Posts: 18110
    
    8

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: http://aspose.com/file-tools
 
subject: java to update jar files
 
Similar Threads
Problem with the use of external library from a jar archive
JWS: Executable jar runs but doesn't show the data
Update jar File
Creating a Jar file under RandomAccesFile usage-A Tantalizing task
How to configure the subprojects as one project in eclipse using Ant?