I installed Oracle Java JDK 8 but java command line is still reporting it is version 7 [duplicate]

Solution 1:

Java 7 and Java 8 are installed under /Library/Java/JavaVirtualMachines, and to get informations about the installed Java VM's you can use the /usr/libexec/java_home command, which is a link/shortcut to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home.

Some of the command to use are:

/usr/libexec/java_home -verbose will give you all installed versions with path.

/usr/libexec/java_home -v '1.6*' will give you JAVA_HOME of Java 6

/usr/libexec/java_home -v '1.7*' will give you JAVA_HOME of Java 7 (if installed)

/usr/libexec/java_home -v '1.8*' will give you JAVA_HOME of Java 8 (if installed)

And if /usr/libexec/java_home is called without any parameters you should get the current enabled (newest) Java version. If you don't get the newest Java version when /usr/libexec/java_home is called, you can try a restart of your Mac, so that the system reload its current load of the /usr/bin/java link/shortcut to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

Solution 2:

I had the same problem on OS X Yosemite 10.9.

The problem was solved by installing the Java SE Development Kit 8.

I had installed the other version that is not a SE development kit and it was just working in web browsers, not for the terminal.