0

What a really need is a java application that checks for new updates from an XML or TXT file from the internet which shows the files that have been updated like the following:

V.1.0.5
class1.java
img/img1.jpg

V.1.0.6
class1.java
class3.java
class4.java

The App. Should check Updated from his Current version to the latest and make a list of the updated files, in this case is should be:

class1.java
img/img1.jpg
class3.java
class4.java

The app Should then download this files from a link like : http://webadress.com/appfiles/XXXXXXX where XXXXXXX is the file name.

The main problem i've faced is How Can the app download and replace this files within the Same app JAR file.

i've thinked about a bootstrap (SecondP App that launch the main app and check for updates . but can't really get it to work , As it should Extract the main app jar replace and download the new update files then re-archive the files in one jar file and launch it .

Simply what i really need is an application that can update it self on file by file bases not replacing the whole jar file. as bandwidth is really a huge matter.

Thanks a lot for help in advance :)

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
Zacktm
  • 13
  • 1
  • 3
  • You can just put the new files into a new jar to replace the old classes. Java will take classes from jars in the order they appear in your class path variable. – flakes Feb 26 '16 at 22:44
  • 2
    Java already has a facility for doing this, and it's part of every Java installation: [Java Web Start](http://docs.oracle.com/javase/8/docs/technotes/guides/javaws/). (Why does this have an `ant` tag?) – VGR Feb 27 '16 at 00:14
  • I suggest standing back and look the systems you use to build and deploy. Let your deployer spot new versions and automatically redeploy the application, rather than expecting the application to upgrade itself. Applications cannot be expected to spot changes to source, download and compile these locally. – Mark O'Connor Feb 27 '16 at 11:27

1 Answers1

0

You need two separate programs in two separate JVMs: your program and the updater. The updater (possibly on user request) checks what should be downloaded, downloads the files and then warns the user.

The user than saves his work, shuts down the application and tells the updater to patch the application binaries, for example by replacing JARs, updating databases and/or configuration files, symbolic links and whatnot.

I don't know of any framework that can ease the writing of such a system - so likely you'll have to code every piece of code by yourself. Since it's not an easy task, you should consider the conservative alternative of simply writing a wizard (there are frameworks for this) that completely replaces the binaries and works for both first installation and upgrade. Also, consider that sometimes you'll need the updater to upgrade itself!

Raffaele
  • 20,627
  • 6
  • 47
  • 86