Skip to content

Commit

Permalink
Nextflow launch script: improving search for JAVA_CMD (nextflow-io#4830)
Browse files Browse the repository at this point in the history
Signed-off-by: Dr Marco Claudio De La Pierre <marco.delapierre@gmail.com>
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
Co-authored-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
Signed-off-by: Niklas Schandry <niklas@bio.lmu.de>
  • Loading branch information
2 people authored and nschan committed Apr 3, 2024
1 parent 34726ba commit 87cbdec
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion nextflow
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ if [ ! -x "$JAVA_CMD" ] ; then
JAVA_CMD="$JAVA_HOME/bin/java"
fi
elif [ -x /usr/libexec/java_home ]; then
JAVA_CMD="$(/usr/libexec/java_home -v 1.8+)/bin/java"
JAVA_CMD="$(/usr/libexec/java_home -v 11+ 2>/dev/null)/bin/java" || JAVA_CMD=java
else
JAVA_CMD="$(which java)" || JAVA_CMD=java
fi
Expand All @@ -288,7 +288,13 @@ if [ -f "$JAVA_KEY" ]; then
else
JAVA_VER="$("$JAVA_CMD" $NXF_OPTS -version 2>&1)"
if [ $? -ne 0 ]; then
getstarted_web="https://www.nextflow.io/docs/latest/getstarted.html"
echo_red "${JAVA_VER:-Failed to launch the Java virtual machine}"
echo_red "NOTE: Nextflow needs a Java virtual machine to run. To this end:
- make sure a \`java\` command can be found; or
- manually define the variables JAVA_HOME to point to an existing installation; or
- install a Java virtual machine, for instance through https://sdkman.io (read the docs);
- for more details please refer to the Nextflow Get Started page at ${getstarted_web}."
echo_yellow "NOTE: Nextflow is trying to use the Java VM defined by the following environment variables:\n JAVA_CMD: $JAVA_CMD\n NXF_OPTS: $NXF_OPTS\n"
exit 1
fi
Expand Down

0 comments on commit 87cbdec

Please sign in to comment.