Self-renewal program

So, this is what has been in my opinion for a while. How can you take the program and make it "automatic update". So, let's say, an external shell that checks Myserver.com/myProg/updates.xml (or some other resource) and checks that the version numbers are the same. As soon as I do this, how do I handle the program update?

Let's say that my program was a simple main class, and the only way out is:

System.out.println ("Hello World"); When upgrading, it turns into System.out.println ("Hello Java");

How can I get this change in place at runtime?

Note. JNLP is not applicable for this because of signature issues that I do not want to extend.

+7
source share
2 answers

You need 2 "applications":

  • Minimum bootable application that checks for updates and launches the main application;
  • The main application.

The user always starts the boot application, not the main application (in fact, the user does not know about the boot application). This is by far the most common pattern I've seen.

If you want to do automatic updates at runtime, you need to use OSGI as indicated by javabeats. But use this way if you really need to. I have never used OSGI, but I can imagine that this is not trivial.

Edit

I have no concrete example, but I can imagine that

  • bootstrap loads some jar files and configurations
  • One of the configuration files contains the files necessary in the class path (this can be done automatically by your application if it selects all jar files inside this folder).
  • In the previous list, create a new class loader (see the example here ) to add jar files to the class path.
  • Run the main application class in the new classloader.

Sorry, I can’t give you a more detailed answer without writing the code myself, but I take it :).

+9
source

If JNLP is excluded, I think that only a solution using OSGI will achieve this. Otherwise, even with the simplest design, you will need another program to manage and download versions of your current program.

+2
source

All Articles