InternetTowers
InternetTowers

Reputation: 63

Switching from java 1.6 to 1.8 on a mac

I got a new mac and need to install java version 8. I downloaded it from oracle and when I run their app on their website, it says that I have the most recent version of java. When I run "java -version" is says that I am still using 1.6. How do I change this?

According to java control panel I have 1.8. However when working in eclipse it is still using 1.6.0_65. I tried uninstalling and it was unsuccessful.

My java virtual machine folder only contains 1.6.0.jdk. Do I need to move 1.8 to this folder?

Upvotes: 1

Views: 6060

Answers (4)

sidtagirisa
sidtagirisa

Reputation: 86

When you do java -version it gives the output of current jdk in use. For that to update we need to download jdk for mac here and install it.

Go to the following url and download the appropriate file. http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Upvotes: 3

slal
slal

Reputation: 2867

You can use jenv to switch between Java versions, it is like a Java environment manager. It is super easy to use and clean

For Mac, follow the steps:

brew install jenv

git clone https://github.com/gcuisinier/jenv.git ~/.jenv

Installation: If you are using bash follow these steps:

$ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile

echo 'eval "$(jenv init -)"' >> ~/.bash_profile

$ exec $SHELL -l

Add desired versions of JVM to jenv:

jenv add /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

jenv add /System/Library/Java/JavaVirtualMachines/1.8.0.jdk/Contents/Home

Check the installed versions:

jenv versions

Set the Java version you want to use by:

jenv global oracle64-1.6.0

Upvotes: 0

Arpit Aggarwal
Arpit Aggarwal

Reputation: 29276

For eclipse to use Java 8 instead of Java 6, follow below steps:

  1. Click Eclipse and then Select Preferences.
  2. Search for Compiler in "type filter text" search box.
  3. Select Compiler under Java.
  4. Change JDK Compliance to 1.8

Upvotes: 0

matsev
matsev

Reputation: 33779

Two options:

  • Uninstall Java 6.
  • Alternatively, check this script (based on this answer at superuser.com) created by a colleague of mine if you would like to switch between multiple Java versions.

Upvotes: 0

Related Questions