picking which jdk to run

I have an app (nifi) which does not work on JDK 9, so I want to swicth the JDK Version.

List Possible Versions

This is the command

 /usr/libexec/java_home -V

And the correctponing output

Matching Java Virtual Machines (2):
    9.0.1, x86_64:  "Java SE 9.0.1" /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home
    1.8.0_151, x86_64:  "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home

Set your Java-Home

For picking just a major Version you can do this

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

Run App (nifi)

I now just need to select this Java, export it. And run the startup script...

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
tim@T-Mac-mini bin $ java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
tim@Timothys-Mac-mini bin $ ./nifi.sh run

It now works.