aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-application/src/main/assembly/bin/windows-x86-64/lib/find_java.bat
blob: 82ca851821f399e175360740ff1ff88d82fba16a (plain)
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
@echo off
call:%~1
goto exit

rem Sets the JAVA_EXE var to be used by the calling script.
rem By default, the java.exe in the PATH is selected. This can be overwritten by the environmental variable SONAR_JAVA_PATH.
rem Returns an error code if Java executable is not found in the PATH and the environmental variable SONAR_JAVA_PATH is not properly set.
:set_java_exe
    rem use java.exe from PATH, by default
    where "java.exe" >nul 2>nul
    if %errorlevel% equ 0 (
        set JAVA_EXE="java.exe"
    )

    rem if the environmental variable SONAR_JAVA_PATH is set, override the default java.exe
    if not "%SONAR_JAVA_PATH%"=="" (
        if exist "%SONAR_JAVA_PATH%" (
            set JAVA_EXE="%SONAR_JAVA_PATH%"
        ) else (
            echo ERROR: "%SONAR_JAVA_PATH%" not found. Please make sure that the environmental variable SONAR_JAVA_PATH points to the Java executable.
            exit /b 1
        )
    )

    if [%JAVA_EXE%]==[] (
        echo ERROR: java.exe not found. Please make sure that the environmental variable SONAR_JAVA_PATH points to the Java executable.
        exit /b 1
    )
    exit /b 0

:exit
exit /b