If you need to upgrade your java version on osx, it may not be as simple as it seems.
You can try many things people suggest on this post, but I found out that the easiest way is to simply install the JDK8.
The download page is below, look for jdk-8u11-macosx-x64.dmg.
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Then after installing, you will have the upgraded java version in the terminal.
localhost username$ java -version java version "1.8.0_11" Java(TM) SE Runtime Environment (build 1.8.0_11-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)