We want to implement a feature like this: when user firstly run the app, app will download a jar file to local PC from a server and load the jar file but when user run the app again, app can distinguish if the content of the jar file in local folder is same as the one on server, if so not download it again just load it from local folder; if not app will download it and update local one (the jar file name on server and on local must be same). Currently one solution I can think out is to use checksum that is app generates the checksum of local jar file then get the checksum of server jar file from the server, check if they are same, if so not download again, if not download and update. Is there a simple way to generate checksum of a jar file? Or is there any other better solution for this feature? Thanks.
Asked
Active
Viewed 1.2k times
4 Answers
3
Calculating the jar checksum is the same as calculating the checksum of any file. But it looks like you need Java Web Start, which will take care of everything.

Bozho
- 588,226
- 146
- 1,060
- 1,140
-
I know that JWS can take care of version problem but in my case we can't use JWS for some special reasons. – Eric Jiang Sep 19 '11 at 09:34
0
If you are building the jar file with maven there is a maven plug-in for generating check-sums of a compiled jar. Maven Plugin Link .
As for the downloaded jar you can locally SAVE ,rather than generate, the jars check sum. Fetch the check-sum from the server and send a request to the it every time you need to check if the jars check sum is changed and if so download the new one.

Adelin
- 18,144
- 26
- 115
- 175
0
Java Web Start is certainly the right way to do it as Bozho says. For a hand-made alternative see What's the best way to add a self-update feature to a Java Swing application?

Community
- 1
- 1

Miserable Variable
- 28,432
- 15
- 72
- 133