Files

80 lines
2.2 KiB
Batchfile

@echo off
setlocal enabledelayedexpansion
REM ============================================================
REM Eclipse JDT Language Server - Windows Startup Script
REM Version: 1.57.0-202602111032
REM ============================================================
REM --- Resolve JDTLS base directory (where this script lives) ---
set "JDTLS_HOME=%~dp0"
REM Remove trailing backslash
if "%JDTLS_HOME:~-1%"=="\" set "JDTLS_HOME=%JDTLS_HOME:~0,-1%"
REM --- Check JAVA_HOME or java on PATH ---
if defined JAVA_HOME (
set "JAVA=%JAVA_HOME%\bin\java.exe"
) else (
where java >nul 2>&1
if errorlevel 1 (
echo ERROR: Java not found. Set JAVA_HOME or add java to PATH.
exit /b 1
)
set "JAVA=java"
)
echo Using Java: %JAVA%
"%JAVA%" -version 2>&1 | findstr /i "version"
REM --- Find the launcher JAR ---
set "LAUNCHER="
for %%f in ("%JDTLS_HOME%\plugins\org.eclipse.equinox.launcher_*.jar") do (
set "LAUNCHER=%%f"
)
if not defined LAUNCHER (
echo ERROR: Cannot find org.eclipse.equinox.launcher_*.jar in plugins/
exit /b 1
)
echo Using launcher: %LAUNCHER%
REM --- Configuration directory (Windows) ---
set "CONFIG_DIR=%JDTLS_HOME%\config_win"
REM --- Workspace data directory ---
REM Each project should use a separate workspace to avoid conflicts.
REM You can override this by setting JDTLS_WORKSPACE before running.
if not defined JDTLS_WORKSPACE (
set "JDTLS_WORKSPACE=%APPDATA%\jdtls\workspace"
)
if not exist "%JDTLS_WORKSPACE%" (
mkdir "%JDTLS_WORKSPACE%"
)
echo Using config: %CONFIG_DIR%
echo Using workspace: %JDTLS_WORKSPACE%
echo.
REM --- Launch JDTLS ---
"%JAVA%" ^
-Declipse.application=org.eclipse.jdt.ls.core.id1 ^
-Dosgi.bundles.defaultStartLevel=4 ^
-Declipse.product=org.eclipse.jdt.ls.core.product ^
-Dlog.level=ALL ^
-Xmx1G ^
--add-modules=ALL-SYSTEM ^
--add-opens java.base/java.util=ALL-UNNAMED ^
--add-opens java.base/java.lang=ALL-UNNAMED ^
-jar "%LAUNCHER%" ^
-configuration "%CONFIG_DIR%" ^
-data "%JDTLS_WORKSPACE%"
echo.
echo ============================================================
echo JDTLS exited with code: %ERRORLEVEL%
echo ============================================================
pause
endlocal