El Capitan, how to choose a specific Java version to run I'm running El Capitan and java -version produces the following:

java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)


I'm having severe slowdown problems with the h2 database console, so I want to see if going back to Java 1.6 has any effect.

I run the Java Preferences application and move 1.6 so it's at the top, but the next time I launch Java Preferences 1.8 is back up there!  Even unchecking 1.8 doesn't persist -- it's rechecked on the next launch.

How does one go about selecting a particular Java version these days?
Maybe just put the following in your ~/.bashrc:

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