Question: I am having an issue trying to upgrade to Java 8 from Java 6 on my Mac running Mac OS X 10.10.5, with Java 8 seemingly not getting recognized.

I installed Java 8 via the .dmg installer: jre-8u66-macosx-x64.dmg, yet when I enter: java -version, it reports:
java version "1.6.0\_65".

Yet, I noticed under the Java Panel via System Preference, the Java Runtime Environment Settings Panel is displaying 1.8.0\_102.

From poking around I have noticed:
1) Java 8 seems to have installed into: /Library/Java/JavaVirtualMachines/jdk1.8.0\_102.jdk

2) Java 6 seems to have been installed into:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk

I then noticed a post on StackOverflow recommending to use "brew" to install Java, and not use the official installer for Mac, as it is broken. When I went to install brew I got this error message:

/usr/bin/ruby -e "$(curl -fsSL <https://raw.githubusercontent.com/Homebrew/install/master/install>)"

I got this error message: Illegal variable name.
And then I read that "brew" is broken on versions of El Capitan and above.

So, what do I need to do to get this upgrade to Java 8 to work???
Appreciate any help with this! Thanks!

Answer: 
your java command points to the stub binary which uses current version configured

```
$ ls -la /usr/bin/java
lrwxr-xr-x  1 root  wheel  74 Feb  5  2015 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

```

all you need is to update your `JAVA_HOME`(I've added that to my `~/.profile`):

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

```

There's a topic which describes this in-depth [Need help understanding Oracle's Java on Mac](https://stackoverflow.com/questions/15120745/need-help-understanding-oracles-java-on-mac)
1. set your JAVE\_HOME to java 8.
2. For the brew thing, guess you might have run it in csh/tcsh..change it to bash and the script will working to install brew.