Skip to main content
Bumped by Community user
deleted 10 characters in body
Source Link

I have an application which requires JAVA_HOME environment to be set for a successfull running. On the RHEL server, however the current version of java points to "openjdk version "1.8.0_302".

Below is the service file I have configured so that it can execute only through a specific user and also defined JAVA_HOME path.

[Service]
Type=simple
User=testuser
Restart=always
RestartSec=5sec
IgnoreSIGPIPE=no
KillMode=process
Environment="OPENICF_OPTS=-Xmx1024m"
Environment=JAVA_HOME=/path to jdk/JDK/jdk-11.0.15.1/
ExecStart=/path to conf file/bin/Connect.sh /start

On enabling and starting this service, this is still executing the shell script using openjdk 1.8 version which is not compatible with the application. Hence, the service fails to start and become active.

For the reference, below is a brief snippet of my shell script Connect.sh. In the bash script, you can see how the java variable is defined.

# Check Java availability
if type -p 'java' >/dev/null; then
    JAVA=java
elif [ -n "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/java" ];  then
    JAVA="$JAVA_HOME/bin/java"
else
    echo JAVA_HOME not available, Java is needed to run the Connector Server
    echo Please install Java and set the JAVA_HOME accordingly
    exit 1
fi

Can anyone please help me in resolving this issue? I am not able to figure out what I am doing wrong here.

I have an application which requires JAVA_HOME environment to be set for a successfull running. On the RHEL server, however the current version of java points to "openjdk version "1.8.0_302".

Below is the service file I have configured so that it can execute only through a specific user and also defined JAVA_HOME path.

[Service]
Type=simple
User=testuser
Restart=always
RestartSec=5sec
IgnoreSIGPIPE=no
KillMode=process
Environment="OPENICF_OPTS=-Xmx1024m"
Environment=JAVA_HOME=/path to jdk/JDK/jdk-11.0.15.1/
ExecStart=/path to conf file/bin/Connect.sh /start

On enabling and starting this service, this is still executing the shell script using openjdk 1.8 version which is not compatible with the application. Hence, the service fails to start and become active.

For the reference, below is a brief snippet of my shell script Connect.sh. In the bash script, you can see how the java variable is defined.

# Check Java availability
if type -p 'java' >/dev/null; then
    JAVA=java
elif [ -n "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/java" ];  then
    JAVA="$JAVA_HOME/bin/java"
else
    echo JAVA_HOME not available, Java is needed to run the Connector Server
    echo Please install Java and set the JAVA_HOME accordingly
    exit 1
fi

Can anyone please help me in resolving this issue? I am not able to figure out what I am doing wrong here.

I have an application which requires JAVA_HOME environment to be set for a successfull running. On the RHEL server, however the current version of java points to "openjdk version "1.8.0_302".

Below is the service file I have configured so that it can execute only through a specific user and also defined JAVA_HOME path.

[Service]
Type=simple
User=testuser
Restart=always
RestartSec=5sec
IgnoreSIGPIPE=no
KillMode=process
Environment="OPENICF_OPTS=-Xmx1024m"
Environment=JAVA_HOME=/path to jdk/JDK/jdk-11.0.15.1/
ExecStart=/path to conf file/bin/Connect.sh /start

On enabling and starting this service, this is still executing the shell script using openjdk 1.8 version which is not compatible with the application. Hence, the service fails to start and become active.

For the reference, below is a brief snippet of my shell script Connect.sh. In the bash script, you can see how the java variable is defined.

# Check Java availability
if type -p 'java' >/dev/null; then
    JAVA=java
elif [ -n "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/java" ];  then
    JAVA="$JAVA_HOME/bin/java"
else
    echo JAVA_HOME not available, Java is needed to run the Server
    echo Please install Java and set the JAVA_HOME accordingly
    exit 1
fi

Can anyone please help me in resolving this issue? I am not able to figure out what I am doing wrong here.

Source Link

Refer another Java version in a systemd service file

I have an application which requires JAVA_HOME environment to be set for a successfull running. On the RHEL server, however the current version of java points to "openjdk version "1.8.0_302".

Below is the service file I have configured so that it can execute only through a specific user and also defined JAVA_HOME path.

[Service]
Type=simple
User=testuser
Restart=always
RestartSec=5sec
IgnoreSIGPIPE=no
KillMode=process
Environment="OPENICF_OPTS=-Xmx1024m"
Environment=JAVA_HOME=/path to jdk/JDK/jdk-11.0.15.1/
ExecStart=/path to conf file/bin/Connect.sh /start

On enabling and starting this service, this is still executing the shell script using openjdk 1.8 version which is not compatible with the application. Hence, the service fails to start and become active.

For the reference, below is a brief snippet of my shell script Connect.sh. In the bash script, you can see how the java variable is defined.

# Check Java availability
if type -p 'java' >/dev/null; then
    JAVA=java
elif [ -n "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/java" ];  then
    JAVA="$JAVA_HOME/bin/java"
else
    echo JAVA_HOME not available, Java is needed to run the Connector Server
    echo Please install Java and set the JAVA_HOME accordingly
    exit 1
fi

Can anyone please help me in resolving this issue? I am not able to figure out what I am doing wrong here.