From 9341d4b229cd9fc0439e76942087f9d0798da36e Mon Sep 17 00:00:00 2001 From: Felix Hilgerdenaar Date: Tue, 26 Nov 2024 14:39:09 +0100 Subject: [PATCH 1/3] feat(bundle): build path to java binary with JAVA_HOME if set --- bundle/src/assembly/resources/bin/mosaic.bat | 8 +++++++- bundle/src/assembly/resources/bin/mosaic.sh | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/bundle/src/assembly/resources/bin/mosaic.bat b/bundle/src/assembly/resources/bin/mosaic.bat index 2a38206ae..450b883e9 100644 --- a/bundle/src/assembly/resources/bin/mosaic.bat +++ b/bundle/src/assembly/resources/bin/mosaic.bat @@ -7,6 +7,12 @@ set javaMemorySizeXmx=2G REM uncomment to activate remote debugging REM set javaRemoteDebugging=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=10000 +if "%JAVA_HOME%"=="" ( + set java_bin=java +) else ( + set java_bin=%JAVA_HOME%\bin\java +) + set libs= rem core components @@ -25,7 +31,7 @@ if not "!libs!" == "" set libs=!libs!; set libs=!libs!; -java -Xmx%javaMemorySizeXmx% %javaRemoteDebugging% -cp !libs! org.eclipse.mosaic.starter.MosaicStarter %* +%java_bin% -Xmx%javaMemorySizeXmx% %javaRemoteDebugging% -cp !libs! org.eclipse.mosaic.starter.MosaicStarter %* EndLocal diff --git a/bundle/src/assembly/resources/bin/mosaic.sh b/bundle/src/assembly/resources/bin/mosaic.sh index abeba4845..57e553dad 100644 --- a/bundle/src/assembly/resources/bin/mosaic.sh +++ b/bundle/src/assembly/resources/bin/mosaic.sh @@ -7,6 +7,13 @@ javaMemorySizeXmx="2g" # uncomment to activate remote debugging # javaRemoteDebugging="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=10000" +# check if JAVA_HOME is set and define path to java binary accordingly (variable: java_bin) +if [ -z "${JAVA_HOME}" ]; then + java_bin=java +else + java_bin=${JAVA_HOME}/bin/java +fi + # mosaic dir_mosaic=./lib/mosaic tmp=`ls ${dir_mosaic} | grep jar` @@ -18,5 +25,5 @@ tmp=`ls ${dir_libs} | grep jar` libs=${dir_libs}/${tmp//[^A-Za-z0-9\-\.]/:${dir_libs}/} # create and run command -cmd="java -Xmx${javaMemorySizeXmx} ${javaRemoteDebugging} -cp .:${mosaic}:${libs} org.eclipse.mosaic.starter.MosaicStarter $*" +cmd="${java_bin} -Xmx${javaMemorySizeXmx} ${javaRemoteDebugging} -cp .:${mosaic}:${libs} org.eclipse.mosaic.starter.MosaicStarter $*" $cmd From f4eb2ee9cf514f875867005d1cf979cf199b0b9b Mon Sep 17 00:00:00 2001 From: Felix Hilgerdenaar Date: Tue, 26 Nov 2024 15:16:27 +0100 Subject: [PATCH 2/3] doc(mosaic.bat): missing comment added --- bundle/src/assembly/resources/bin/mosaic.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/bundle/src/assembly/resources/bin/mosaic.bat b/bundle/src/assembly/resources/bin/mosaic.bat index 450b883e9..8c566cfb4 100644 --- a/bundle/src/assembly/resources/bin/mosaic.bat +++ b/bundle/src/assembly/resources/bin/mosaic.bat @@ -7,6 +7,7 @@ set javaMemorySizeXmx=2G REM uncomment to activate remote debugging REM set javaRemoteDebugging=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=10000 +REM check if JAVA_HOME is set and define path to java binary accordingly (variable: java_bin) if "%JAVA_HOME%"=="" ( set java_bin=java ) else ( From 3a8ed029904008a0ea5ca21762eb2eb145dbd06b Mon Sep 17 00:00:00 2001 From: Felix Hilgerdenaar Date: Tue, 26 Nov 2024 16:10:16 +0100 Subject: [PATCH 3/3] fix(bundle): accomodate for spaces in JAVA_HOME --- bundle/src/assembly/resources/bin/mosaic.bat | 2 +- bundle/src/assembly/resources/bin/mosaic.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bundle/src/assembly/resources/bin/mosaic.bat b/bundle/src/assembly/resources/bin/mosaic.bat index 8c566cfb4..79b5c61fc 100644 --- a/bundle/src/assembly/resources/bin/mosaic.bat +++ b/bundle/src/assembly/resources/bin/mosaic.bat @@ -32,7 +32,7 @@ if not "!libs!" == "" set libs=!libs!; set libs=!libs!; -%java_bin% -Xmx%javaMemorySizeXmx% %javaRemoteDebugging% -cp !libs! org.eclipse.mosaic.starter.MosaicStarter %* +"%java_bin%" -Xmx%javaMemorySizeXmx% %javaRemoteDebugging% -cp !libs! org.eclipse.mosaic.starter.MosaicStarter %* EndLocal diff --git a/bundle/src/assembly/resources/bin/mosaic.sh b/bundle/src/assembly/resources/bin/mosaic.sh index 57e553dad..6bf57629f 100644 --- a/bundle/src/assembly/resources/bin/mosaic.sh +++ b/bundle/src/assembly/resources/bin/mosaic.sh @@ -25,5 +25,5 @@ tmp=`ls ${dir_libs} | grep jar` libs=${dir_libs}/${tmp//[^A-Za-z0-9\-\.]/:${dir_libs}/} # create and run command -cmd="${java_bin} -Xmx${javaMemorySizeXmx} ${javaRemoteDebugging} -cp .:${mosaic}:${libs} org.eclipse.mosaic.starter.MosaicStarter $*" -$cmd +cmd="\"${java_bin}\" -Xmx${javaMemorySizeXmx} ${javaRemoteDebugging} -cp .:${mosaic}:${libs} org.eclipse.mosaic.starter.MosaicStarter $*" +eval $cmd