Search code examples
javamacososx-elcapitan

Unable to switch to Java 1.6 on El Capitan


I'm running the following command to try to switch to Java 1.6

$export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)

But am getting the error

-bash: JAVA_HOME=/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home: No such file or directory

Yet the directory in the error message does exist: enter image description here


Solution

  • You have to leave the preceding dollar-sign off (export instead of $export):

    export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)