Configuring start up services and scripts for use with Java 17 and above

This documentation is valid only for Console/Nodes ≤ 1.27.0. All more recent 1.x and ≥ 2.x releases support Java ≥ 17 out of the box.

Introduction

Java 17+ is more restrictive regarding java library use and limits some elements to specific modules that are not enabled by default. As a result of this, although supported for use with Console, the Microsoft Windows Service installation scripts and the start up batch/script files delivered with the installer for the Console front-end and back-end Node must be modified before they can be used to launch or install Console or a Node:

The following files must be changed if you are running Java 17+. Instructions are provided below. If you have multiple Nodes, and all require Java 17+, ensure you update all files on all Nodes.

Microsoft Windows (Console front-end and Node back-end):

%PROGRAMFILES%\CAST\AipConsole\AipNode\tools\runAipNode.bat
%PROGRAMFILES%\CAST\AipConsole\AipConsole\tools\runAIPConsole.bat
%PROGRAMFILES%\CAST\AipConsole\AipNode\tools\aip-node-service-install.bat
%PROGRAMFILES%\CAST\AipConsole\AipConsole\tools\aip-console-service-install.bat

Linux:

Console front-end only:
$HOME\CAST\AipConsole\tools\runAIPConsole.sh

Microsoft Windows

runAipNode.bat / runAIPConsole.bat

Add the following line before the -jar command:

--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED

For example:

runAipNode.bat
@echo off
TITLE AIP Node

cd..
java -version
java --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED -jar -Xmx1024m -Xms256m "bin/aip-node-app.jar"
if %errorlevel% neq 0 exit /b %errorlevel%
runAIPConsole.bat
@echo off
TITLE Starting AIP Console...

REM Get the AIP Console directory from tools location
for %%i in ("%~dp0..") do set "CONSOLE_FOLDER=%%~fi"

echo Checking JAVA version
java -version
if %errorlevel% neq 0 goto done
REM start AIP Console inside the console folder to avoid "cd" when starting from another place
start "AIP Console" /D "%CONSOLE_FOLDER%" java --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED -jar -Xmx1024m -Xms256m "bin/aip-console-app.jar"
if %errorlevel% neq 0 goto done

:: After 20s (to let AIP Console start), open the browser to AIP Console's UI
echo.
echo Waiting for AIP Console to be available.
timeout 20 > nul
start http://localhost:8081/ui/index.html
set errorlevel=0

:done
exit /B %errorlevel%

aip-node-service-install.bat / aip-console-service-install.bat

Edit the files and replace ALL the code after the line starting set PATH_TO_JVM with the code listed below. If you have already installed the Windows Services as part of the installation process, you must re-execute these files to update the installed Windows Services:

set JAVA16_OPTS="--add-opens=java.base/java.lang=ALL-UNNAMED;--add-opens=java.naming/com.sun.jndi.ldap=ALL-UNNAMED"
 
set START_AFTER_INSTALL="%~1"
set IS_USER_ACCOUNT="%~2"
set SERVICE_USER="%~3"
set SERVICE_PASSWORD="%~4"
 
if %OS_ARCH%==x86 (cd tools) else (cd tools\amd64)
 
%SERVICE_NAME% delete
%SERVICE_NAME% install --DisplayName %DISPLAY_NAME% --Description %DESCRIPTION% --Startup %STARTUP_TYPE% ^
	--StartMode jvm --StartClass %START_CLASS% --StartPath %START_PATH% ^
	--StopMode jvm --StopClass %STOP_CLASS% --StopParams %STOP_PARAMS% --StopTimeout 45 ^
	--Jvm %PATH_TO_JVM% --Classpath %JAR_PATH%  --JvmMx 1024 --JvmMs 256 ++JvmOptions9=%JAVA16_OPTS%
 
if %IS_USER_ACCOUNT%=="true" %SERVICE_NAME% update --ServiceUser %SERVICE_USER% --ServicePassword %SERVICE_PASSWORD%
if %START_AFTER_INSTALL%=="true" %SERVICE_NAME% start

Linux

runAIPConsole.sh

Add the following line into the JAVA_OPTS parameter:

--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED

For example:

runAIPConsole.sh
#!/usr/bin/env bash
# Runs AIP Console on Linux
# Requires the java executable in the path or the JAVA_HOME environment variable defined
# Any parameters passed to this executable will be passed on to the Java launcher
# example : ./runAIPConsole.sh --debug will start AIP Console in debug mode

CURRENT_DIR="$(dirname "$0")"

JAVA_CMD=java
if ! java_loc="$(type -p java)" || [[ -z $java_loc ]]; then
if [[ -n $JAVA_HOME ]]; then
echo "Java not found on your system. Make sure the java executable is in the PATH or that JAVA_HOME environment variable is defined"
exit 1
fi
JAVA_CMD=$JAVA_HOME/bin/java
fi

JAVA_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED -Xmx1024m -Xms256m"
JAR_LOC="$CURRENT_DIR/../bin/aip-console-app.jar"

# Set terminal title
echo -e '\033]2;AIP Console\007'

echo "Java version :"
$JAVA_CMD -version
echo "----------------------------------------------------------------------"
echo " Starting AIP Console "
echo "----------------------------------------------------------------------"
# shecllcheck disable=SC2086
$JAVA_CMD $JAVA_OPTS -jar "$JAR_LOC" "$@"