JavaRush /Java Blog /Random EN /Getdown or How to configure java application updates
IvanDurov
Level 25

Getdown or How to configure java application updates

Published in the Random EN group

Metafiles

Getdown uses two metafiles: getdown.txt and digest.txt . You create the getdown.txt file yourself (there will be a description below), and our program will create the digest.txt file based on the files in your project.

getdown.txt

The getdown.txt file stores everything Getdown needs to run and update your application. Now we will describe the standard getdown.txt structure , and you can read the full description of all the possibilities. This is what a standard getdown.txt looks like :
# URL address of the folder from where the client program will download updates appbase = http://myapplication.com/myapp/ # User interface configuration file ui.name = My Application # All jar files of your application code = application.jar # Class in which your method is located main(String[] args) class = myapplication.MyApplication
appbase contains the URL where your application will be downloaded from and two metafiles. In our case, the full path to the application and metafiles will look like this:
  • http://myapplication.com/myapp/getdown.txt
  • http://myapplication.com/myapp/digest.txt
  • http://myapplication.com/myapp/application.jar

digest.txt

digest.txt will be created by the com.threerings.getdown.tools.Digester utility . To do this, download getdown-XYjar . And so, in your folder now you have your application and one metafile:
myapp/getdown.txt myapp/application.jar
It's time to create digest.txt , to do this, type in the command line:
% java -classpath getdown-XYjar com.threerings.getdown.tools.Digester myapp
where myapp is the path to the myapp folder in which your application and one metafile are currently located. If you did everything correctly, the following message will appear on the command line:
Generating digest file 'myapp/digest.txt'...
And also the long-awaited second metafile digest.txt will be added to your application folder . Detailed instructions for generating digest.txt can be found here

Server

Now your folder contains everything you need: the application and two metafiles. You can upload it to your server. Do not forget that the address to the folder must be the one specified in getdown.txt in the appbase field . And internal files should be accessible by folder address + file name , i.e. like this:
  • http://myapplication.com/myapp/getdown.txt
  • http://myapplication.com/myapp/digest.txt
  • http://myapplication.com/myapp/application.jar

Checking work

Now let's take the place of the client who will use your application. First, create a folder and drop getdown-XYjar into it . Now let's create getdown.txt which will contain only one line:
appbase = http://myapplication.com/myapp/
Now we write the following command on the command line:
% java -jar myapp/getdown-XYjar myapp
It should compare your files with those on the server if it is necessary to update and run your application. That's all! __________________________________________________________________________________________________________ PS To work with the command line, you can use batch files, this is what create digest.bat looks like :
java -classpath getdown-1.3.1.jar com.threerings.getdown.tools.Digester %CD%
And here is update.bat :
java -jar getdown-1.3.1.jar %CD%
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION