Skip to Main Content

SQLcl

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

sqlcl script ignores JAVA_HOME if java is in the PATH

pbrownOct 10 2023 — edited Oct 10 2023

sqlcl 23.2.0

in the ‘sql’ launch script, the function jdk_version has

if [[ -n $(type -p java) ]]
then
java_cmd=java
elif [[ (-n "$JAVA_HOME") && (-x "$JAVA_HOME/bin/java") ]]
then
java_cmd="$JAVA_HOME/bin/java"
fi

which is saying “if I find java in the PATH then I'll use that instead of the one in the JAVA_HOME you asked me to use”

It should be

if [[ (-n "$JAVA_HOME") && (-x "$JAVA_HOME/bin/java") ]]
then
java_cmd="$JAVA_HOME/bin/java"
elif [[ -n $(type -p java) ]]
then
java_cmd=java
fi

Which says “If you gave me a JAVA_HOME, I'll use the java in there, but if not I'll use the java in the PATH”

Comments
Post Details
Added on Oct 10 2023
14 comments
403 views