Search code examples
javanextflow

Nextflow installation cannot find Java


I'm currently trying to install nextflow on my computer but I'm struggling with a Java error message I can't manage to solve.

curl -s https://get.nextflow.io | bash

ERROR: Cannot find Java or it's a wrong version -- please make sure that Java 8 or later is installed
NOTE: Nextflow is trying to use the Java VM defined by the following environment variables:
 JAVA_CMD: /Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home/bin/java
 JAVA_HOME:

Looking for solution on other posts, I tried to use

export JAVA_HOME="$(/usr/libexec/java_home -v 1.7+)"

but now I still have almost same error

ERROR: Cannot find Java or it's a wrong version -- please make sure that Java 8 or later is installed
NOTE: Nextflow is trying to use the Java VM defined by the following environment variables:
 JAVA_CMD: /Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home/bin/java
 JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home  

My java version :

 java -version
 java version "16.0.2" 2021-07-20
 Java(TM) SE Runtime Environment (build 16.0.2+7-67)
 Java HotSpot(TM) 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing)

I would be grateful if you could give me some tips to overcome this.


Solution

  • Have a look at the script you're running:

    ...
    if [ $major -eq 0 ] && [ $minor -lt 26 ]; then
        version_check="^(1.7|1.8)"
        version_message="Java 7 or 8"
      else
        version_check="^(1.8|9|10|11|12|13|14|15)"
        version_message="Java 8 or later"
      fi
    ...
    

    Looks like it needs Java 15 or earlier. You can probably just add 16 and everything will be fine.