Skip to content

A simple UpdaterAPI for java programs

Notifications You must be signed in to change notification settings

ZeusSeinGrossopa/UpdaterAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UpdaterAPI

UpdaterAPI is a useful Java API for creating a simple Auto-Updater. Its downloading a jar file from a custom url and replace it.

How it works:

  1. Implement the UpdaterAPI class in your Java program (See here)
  2. After starting your Java program it will download the Updater (See here)
  3. Your program starts the downloaded Updater jar before its closing (See here)
  4. The Updater downloading the newest Jar from your Website
  5. The Updater replaces the new Jar with the old
  6. And done!

Work with the API

Here we use the UpdaterAPI class. You need to implement this class in your Java program. The UpdaterAPI uses the Gson & the Apache-Commons-IO library's. These librarys you must implement too in your program

Download the UpdaterAPI

public void start() {
     UpdaterAPI.downloadUpdater(new File("./Updater.jar"));
}

Update with the UpdaterAPI

public void update() {
    File newFile = new File("./YourProgram.jar");
    String url = "www.yoururl.com/api/yourprogram/v1.0/YourProgram.jar";

    try {
        UpdaterAPI.update(url, newFile);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

Other functions

  • Use UpdaterAPI.setAutoDelete(true) that the Updater is only available in the directory, when the program has a new version to update. Default is that the updater is always available in the folder.

Run parameters

  1. This parameter is the url from where the Updater downloads the latest file of your program. (for example: www.yoururl.com/api/yourprogram/v1.0/YourProgram.jar)
  2. Your file of the program what you want to replace (Must be a absoult path)
  3. The new Path location of your program what you want to replace (Must be a absoult path)
  4. (Optional) With the 4. parameter you can restart the jar file