2019-01-07 01:13:57 +01:00
|
|
|
:: This script will download and install the appropriate JDK for use with Bisq development.
|
|
|
|
:: It will also configure it as the default system JDK.
|
|
|
|
:: If you need to change to another default JDK for another purpose later, you just need to
|
|
|
|
:: change the JAVA_HOME environment variable. For example, use the following command:
|
|
|
|
:: setx /M JAVA_HOME "<JDK_PATH>"
|
|
|
|
|
2018-12-04 01:05:59 +01:00
|
|
|
@echo off
|
|
|
|
|
2018-12-15 08:57:26 +01:00
|
|
|
:: Ensure we have administrative privileges in order to install files and set environment variables
|
2018-12-04 01:05:59 +01:00
|
|
|
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
|
|
|
|
if '%errorlevel%' == '0' (
|
|
|
|
::If no error is encountered, we have administrative privileges
|
|
|
|
goto GotAdminPrivileges
|
|
|
|
)
|
|
|
|
echo Requesting administrative privileges...
|
|
|
|
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadminprivileges.vbs"
|
|
|
|
set params = %*:"=""
|
|
|
|
echo UAC.ShellExecute "%~s0", "%params%", "", "runas", 1 >> "%temp%\getadminprivileges.vbs"
|
|
|
|
"%temp%\getadminprivileges.vbs"
|
|
|
|
exit /B
|
|
|
|
:GotAdminPrivileges
|
|
|
|
if exist "%temp%\getadminprivileges.vbs" ( del "%temp%\getadminprivileges.vbs" )
|
|
|
|
pushd "%CD%"
|
|
|
|
cd /D "%~dp0"
|
|
|
|
|
|
|
|
title Install Java
|
|
|
|
|
|
|
|
set jdk_version=10.0.2
|
|
|
|
set jdk_filename=openjdk-%jdk_version%_windows-x64_bin
|
|
|
|
set jdk_url=https://download.java.net/java/GA/jdk10/%jdk_version%/19aef61b38124481863b1413dce1855f/13/%jdk_filename%.tar.gz
|
|
|
|
|
2018-12-07 00:46:39 +01:00
|
|
|
if exist "%PROGRAMFILES%\Java\openjdk\jdk-%jdk_version%" (
|
|
|
|
echo %PROGRAMFILES%\Java\openjdk\jdk-%jdk_version% already exists, skipping install
|
|
|
|
goto SetEnvVars
|
|
|
|
)
|
|
|
|
|
|
|
|
echo Downloading required files to %TEMP%
|
2018-12-04 01:05:59 +01:00
|
|
|
powershell -Command "Invoke-WebRequest %jdk_url% -OutFile $env:temp\%jdk_filename%.tar.gz"
|
2018-12-22 23:59:37 +01:00
|
|
|
if not exist "%TEMP%\7za920\7za.exe" (
|
|
|
|
:: Download 7zip ^(command line version^) in order to extract the tar.gz file since there is no native support in Windows
|
|
|
|
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"
|
|
|
|
)
|
2018-12-04 01:05:59 +01:00
|
|
|
|
2018-12-07 00:46:39 +01:00
|
|
|
echo Extracting and installing JDK to %PROGRAMFILES%\Java\openjdk\jdk-%jdk_version%
|
2018-12-04 01:05:59 +01:00
|
|
|
"%TEMP%\7za920\7za.exe" x "%TEMP%\%jdk_filename%.tar.gz" -o"%TEMP%" -r -y
|
|
|
|
"%TEMP%\7za920\7za.exe" x "%TEMP%\%jdk_filename%.tar" -o"%TEMP%\openjdk-%jdk_version%" -r -y
|
2018-12-07 00:46:39 +01:00
|
|
|
md "%PROGRAMFILES%\Java\openjdk"
|
2018-12-04 01:05:59 +01:00
|
|
|
move "%TEMP%\openjdk-%jdk_version%\jdk-%jdk_version%" "%PROGRAMFILES%\Java\openjdk"
|
|
|
|
|
|
|
|
echo Removing downloaded files
|
2018-12-22 23:59:37 +01:00
|
|
|
if exist "%TEMP%\7za920.zip" (
|
|
|
|
del /Q %TEMP%\7za920.zip
|
|
|
|
)
|
2018-12-04 01:05:59 +01:00
|
|
|
rmdir /S /Q %TEMP%\openjdk-%jdk_version%
|
|
|
|
del /Q %TEMP%\%jdk_filename%.tar
|
|
|
|
del /Q %TEMP%\%jdk_filename%.tar.gz
|
|
|
|
|
2018-12-07 00:46:39 +01:00
|
|
|
:SetEnvVars
|
|
|
|
echo Setting environment variables
|
2018-12-15 08:57:26 +01:00
|
|
|
powershell -Command "[Environment]::SetEnvironmentVariable('JAVA_HOME', '%PROGRAMFILES%\Java\openjdk\jdk-%jdk_version%', 'Machine')"
|
2018-12-07 00:46:39 +01:00
|
|
|
set java_bin=%%JAVA_HOME%%\bin
|
2018-12-15 08:57:26 +01:00
|
|
|
echo %PATH%|find /i "%java_bin%">nul || powershell -Command "[Environment]::SetEnvironmentVariable('PATH', '%PATH%;%java_bin%', 'Machine')"
|
2018-12-07 00:46:39 +01:00
|
|
|
|
2018-12-15 08:57:26 +01:00
|
|
|
echo Done!
|
2018-12-04 01:05:59 +01:00
|
|
|
pause
|