Update install_java.bat

Do not download 7zip if it had previously been downloaded, for example
if this script had previously been run. And don't delete it at the end
of this script in case this script is run again. This is an attempt to
save time and bandwidth.
This commit is contained in:
Devin Bileck 2018-12-22 14:59:37 -08:00
parent 1835ea84ce
commit 01e0c05c2e
No known key found for this signature in database
GPG key ID: C86D829C2399D073

View file

@ -30,9 +30,11 @@ if exist "%PROGRAMFILES%\Java\openjdk\jdk-%jdk_version%" (
echo Downloading required files to %TEMP% echo Downloading required files to %TEMP%
powershell -Command "Invoke-WebRequest %jdk_url% -OutFile $env:temp\%jdk_filename%.tar.gz" powershell -Command "Invoke-WebRequest %jdk_url% -OutFile $env:temp\%jdk_filename%.tar.gz"
:: Download 7zip (command line version) in order to extract the tar.gz file since there is no native support in Windows if not exist "%TEMP%\7za920\7za.exe" (
powershell -Command "Invoke-WebRequest https://www.7-zip.org/a/7za920.zip -OutFile $env:temp\7za920.zip" :: Download 7zip ^(command line version^) in order to extract the tar.gz file since there is no native support in Windows
powershell -Command "Expand-Archive $env:temp\7za920.zip -DestinationPath $env:temp\7za920 -Force" powershell -Command "Invoke-WebRequest https://www.7-zip.org/a/7za920.zip -OutFile $env:temp\7za920.zip"
powershell -Command "Expand-Archive $env:temp\7za920.zip -DestinationPath $env:temp\7za920 -Force"
)
echo Extracting and installing JDK to %PROGRAMFILES%\Java\openjdk\jdk-%jdk_version% echo Extracting and installing JDK to %PROGRAMFILES%\Java\openjdk\jdk-%jdk_version%
"%TEMP%\7za920\7za.exe" x "%TEMP%\%jdk_filename%.tar.gz" -o"%TEMP%" -r -y "%TEMP%\7za920\7za.exe" x "%TEMP%\%jdk_filename%.tar.gz" -o"%TEMP%" -r -y
@ -41,8 +43,9 @@ md "%PROGRAMFILES%\Java\openjdk"
move "%TEMP%\openjdk-%jdk_version%\jdk-%jdk_version%" "%PROGRAMFILES%\Java\openjdk" move "%TEMP%\openjdk-%jdk_version%\jdk-%jdk_version%" "%PROGRAMFILES%\Java\openjdk"
echo Removing downloaded files echo Removing downloaded files
rmdir /S /Q %TEMP%\7za920 if exist "%TEMP%\7za920.zip" (
del /Q %TEMP%\7za920.zip del /Q %TEMP%\7za920.zip
)
rmdir /S /Q %TEMP%\openjdk-%jdk_version% rmdir /S /Q %TEMP%\openjdk-%jdk_version%
del /Q %TEMP%\%jdk_filename%.tar del /Q %TEMP%\%jdk_filename%.tar
del /Q %TEMP%\%jdk_filename%.tar.gz del /Q %TEMP%\%jdk_filename%.tar.gz