Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix install_java.bat when setting long PATH environment variable #2131

Merged
merged 1 commit into from
Dec 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions scripts/install_java.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off

::Ensure we have administrative privileges in order to install files and set environment variables
:: Ensure we have administrative privileges in order to install files and set environment variables
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' == '0' (
::If no error is encountered, we have administrative privileges
Expand Down Expand Up @@ -30,7 +30,7 @@ if exist "%PROGRAMFILES%\Java\openjdk\jdk-%jdk_version%" (

echo Downloading required files to %TEMP%
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
:: 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"

Expand All @@ -49,8 +49,9 @@ del /Q %TEMP%\%jdk_filename%.tar.gz

:SetEnvVars
echo Setting environment variables
setx /M JAVA_HOME "%PROGRAMFILES%\Java\openjdk\jdk-%jdk_version%"
powershell -Command "[Environment]::SetEnvironmentVariable('JAVA_HOME', '%PROGRAMFILES%\Java\openjdk\jdk-%jdk_version%', 'Machine')"
set java_bin=%%JAVA_HOME%%\bin
echo %PATH%|find /i "%java_bin%">nul || setx /M PATH "%PATH%;%java_bin%"
echo %PATH%|find /i "%java_bin%">nul || powershell -Command "[Environment]::SetEnvironmentVariable('PATH', '%PATH%;%java_bin%', 'Machine')"

echo Done!
pause