Updating JARS on the WEB Server
On the surface updating the jars that make up your JAWS application is easy. 1) Create the Jar files, 2) copy them to the right folder on the web server.
In reality - you do not want to change the date on any jars that have not changed so your users will not have to down load them needlessly.
The java program that creates jars has no way to check to see if a jar needs to be updated. This means you create a new jar every time. This in turn means the file date is updated which in turn means that the users downloads the "new" copy.
My solution - use the DOS version of PKZIP (downloadable from hotfiles.com) to create a zip file that matches the jar file. PKZIP does throw an ERRORLEVEL if you tell it to update and nothing has changed. This allows you to create a batch file that only creates and uploads jars that have been changed. Example below.
ECHO OFF
ECHO ********************************************
ECHO Objective - take a set of jar files and send only those that have
ECHO something in them that has changed to the Java Web Start
ECHO web server
ECHO Steps
ECHO 1. clear the work folder l:\javadeliver of *.zip and *.jar files
ECHO 2. set the archive bit off on a set of zip files.
ECHO 3. run pkzip -U (for update) against zip files that look exactly
ECHO like the jar files. It will say NOTHING TO DO! if no changes were made.
ECHO It also sets the ERRORLEVEL to something other than zero
ECHO 4. Check for errorlevel 0 If "yes", then do the jar and copy it
ECHO to the working folder, otherwise skip to the next file.
ECHO 5. zip the second file and check the errorlevel. If it is 0, make
ECHO the jar file and copy it to the working folder
ECHO 6. repeat step 5 for all jar files
ECHO 7. run the "MakeJarRunnable command on the primary files if it is there.
ECHO 8. run the jarsigner on each jar files in the working folder
ECHO
ECHO ****************************************************
rem step 1
del l:\javadeliver\*.jar
rem step 2
attrib *.zip -a
rem note this one does not have the recurse into subfolders command.
pkzip -u Deliv.zip manifest.mf *.class *.gif images\*.* src\DeliverPrc\*.class src\DeliverPrc\Images\*.* History.htm
if errorlevel 1 goto :2ndjar
echo creating Deliv.jar
jar cvmf manifest.mf Deliv.jar *.class *.gif images\*.* src\DeliverPrc\*.class src\DeliverPrc\Images\*.* History.htm
copy Deliv.jar l:\javadeliver\Deliver.jar
echo Deliv.jar created and copied
:2ndjar
echo now do the 2nd set
pause
pkzip -rP -u tools.zip org\jdom\*.* src\DeliverPrc\XML\*.* org\postgresql\*.* javax\*.* com\*.* *.xml
if errorlevel 1 goto :3rdjar
echo creating tools.jar
jar cvf tools.jar org\jdom\*.* src\DeliverPrc\XML\*.* org\postgresql\*.* javax\*.* com\*.* *.xml
copy tools.jar l:\javadeliver
echo tools.jar created and copied
:3rdjar
ECHO Note, the Help files is different, it is created by the help system.
ECHO so we just copy it IF CHANGES WERE MADE.
pause
pkzip -rP -u Deliverhelp.zip f:\myjprojects\deliver\src\deliverprc\deliver\*.*
if errorlevel 1 goto :process
copy Deliverhelp.jar l:\javadeliver
echo Help file copied
:process
pause
echo passphrase is ********
if exist l:\javadeliver\deliver.jar echo Signing Deliver.jar
if exist l:\javadeliver\deliver.jar jarsigner -keystore MyKeystore l:\javadeliver\Deliver.jar myself
if exist l:\javadeliver\DeliverHalp.jar echo signing DeliverHelp.jar
if exist l:\javadeliver\DeliverHalp.jar jarsigner -keystore MyKeystore tl:\javadeliver\DeliverHelp.jar myself
if exist l:\javadeliver\tools.jar echo Signing tools.jar
if exist l:\javadeliver\tools.jar jarsigner -keystore MyKeystore l:\javadeliver\tools.jar myself
dir l:\javadeliver\*.*
Echo.
Echo. Note These files are in l:\javadeliver\*.jar Move to web server.
pause
:exit