-
Notifications
You must be signed in to change notification settings - Fork 1
/
repl.bat
56 lines (53 loc) · 2.21 KB
/
repl.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@echo off
setlocal enabledelayedexpansion
set _SCALA_ENV=
if defined JAVACMD ( set _SCALA_ENV=1
) else if defined JAVA_HOME ( set _SCALA_ENV=1
) else if exist "%ProgramFiles%\Amazon Corretto\jdk*" (
call :javacmd "%ProgramFiles%\Amazon Corretto" "jdk*"
if defined _JAVACMD set "JAVACMD=!_JAVACMD!"& set _SCALA_ENV=1
) else if exist "%ProgramFiles%\Eclipse Adoptium\" (
call :javacmd "%ProgramFiles%\Eclipse Adoptium"
if defined _JAVACMD set "JAVACMD=!_JAVACMD!"& set _SCALA_ENV=1
) else if exist "%ProgramFiles%\Microsoft\jdk-*" (
call :javacmd "%ProgramFiles%\Microsoft" "jdk-*"
if defined _JAVACMD set "JAVACMD=!_JAVACMD!"& set _SCALA_ENV=1
) else if exist "%ProgramFiles%\RedHat\java-*" (
call :javacmd "%ProgramFiles%\RedHat" "java-*"
if defined _JAVACMD set "JAVACMD=!_JAVACMD!"& set _SCALA_ENV=1
) else if exist "%ProgramFiles%\SapMachine\JDK\*" (
call :javacmd "%ProgramFiles%\SapMachine\JDK"
if defined _JAVACMD set "JAVACMD=!_JAVACMD!"& set _SCALA_ENV=1
) else if exist "%ProgramFiles%\Zulu\zulu-*" (
call :javacmd "%ProgramFiles%\Zulu" "zulu-*"
if defined _JAVACMD set "JAVACMD=!_JAVACMD!"& set _SCALA_ENV=1
) else if exist "%ProgramFiles%\Java\" (
call :javacmd "%ProgramFiles%\Java"
if defined _JAVACMD set "JAVACMD=!_JAVACMD!"& set _SCALA_ENV=1
) else if exist "%ProgramFiles(x86)%\Java\" (
call :javacmd "%ProgramFiles(x86)%\Java"
if defined _JAVACMD set "JAVACMD=!_JAVACMD!"& set _SCALA_ENV=1
) else if exist "%SystemDrive%\opt\*jdk*" (
call :javacmd "%SystemDrive%\opt\" "*jdk*"
if defined _JAVACMD set "JAVACMD=!_JAVACMD!"& set _SCALA_ENV=1
)
if defined _SCALA_ENV (
call "%~dp0scala.bat"
exit /b !ERRORLEVEL!
) else (
powershell -C "$x = [Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); $res = [Windows.Forms.MessageBox]::show('Environment variable JAVA_HOME or JAVAMCD must be defined', 'Scala 3');
exit /b 1
)
endlocal
@rem output parameter: _JAVACMD
:javacmd
set _JAVACMD=
set "__PATH=%~1"
set "__PATTERN=%~2"
for /f "delims=" %%d in ('dir /ad /b "%__PATH%\%__PATTERN%" 2^>NUL') do (
for /f "delims=" %%f in ('where /r "%__PATH%\%%d\bin" java.exe 2^>NUL') do (
set "_JAVACMD=%%f"
goto :eof
)
)
goto :eof