Taxes45
Taxes45

Reputation: 477

Editing a .jar file with a .jar file

I have written an updater program for my friend to update another program I wrote for her as a going away gift. I have written all the needed code for retriving the class files that are updated from a server and holding them in temporary memory. What I need help with is having the program replace the class files in the first jar file so she doesn't have to do manual updates. Note: The main program is not running during update so no exploding jars.

Upvotes: 1

Views: 247

Answers (2)

creemama
creemama

Reputation: 6665

If Java Web Start is not what you're looking for and if the jar executable is available on your friend's computer (either because a JDK is installed on your friend's machine or you distribute it with your application), you can run

jar uf jar-file input-file(s)

If you want to call the jar executable from within a Java program, just use Runtime.exec. For a more in-depth discussion about updating a JAR via the jar executable, see Sun Developer Network's article "Updating a JAR File."

Upvotes: 2

Andrew Thompson
Andrew Thompson

Reputation: 168825

So long as the app. has a GUI, 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' installation1 for platforms that support Java.

JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update2 (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..

  1. It is easy for the user.
  2. Automatic update is built-in, all the deployer has to do is upload the new Jar.

Upvotes: 2

Related Questions