Skip to content

Commit

Permalink
EV3: Try JAVA_HOME, then 1st available java in PATH on Windows (#1842)
Browse files Browse the repository at this point in the history
* Win EV3:Take 1st available Java in PATH
* Win: use JAVA_HOME to detect JRE + Improve logging
  • Loading branch information
iakov authored Dec 7, 2024
1 parent 931d873 commit 2e5104f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions installer/platform/trik-studio.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
@echo off
title TRIK Studio Safe Mode
FOR /F "tokens=* USEBACKQ" %%F IN (`where java 2^>NUL`) DO (SET JAVA_PATH=%%~dpF)
set PATH=%SystemRoot%;%SystemRoot%\system32;%JAVA_PATH%
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
IF ERRORLEVEL 1 ECHO Failed to enable extensions
TITLE TRIK Studio Safe Mode
rem if JAVA_HOME is missing try to find the first Java executable in PATH
IF DEFINED JAVA_HOME (ECHO JAVA_HOME is "%JAVA_HOME%" && set JAVA_PATH=%JAVA_HOME%\bin) ^
ELSE (
java -version 2>NUL
IF ERRORLEVEL 1 ECHO Missing working java.exe in PATH="%PATH%"
FOR /f "usebackq tokens=1* delims=:" %%F IN (`where java 2^>NUL ^| findstr /n "^"`) DO @IF %%F == 1 ( ECHO Using Java: "%%G" && SET JAVA_PATH=%%~dpG)
)
rem Clear PATH after Java detection attempt
SET PATH=%SystemRoot%;%SystemRoot%\system32
IF "%JAVA_PATH%" == "" ( ECHO Failed to detect Java/JRE ) ELSE (SET PATH=%PATH%;%JAVA_PATH%&& java -version)
ENDLOCAL

%~dp0trik-studio.exe "%*"

0 comments on commit 2e5104f

Please sign in to comment.