1

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?

2
  • 1
    See this question: stackoverflow.com/questions/12757558/… especially the second answer.
    – dguay
    Oct 21, 2015 at 12:53
  • I tried that and am now getting an error when I run eclipse saying "The jvm shared library "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/contents/home/bin/.../lib/server/libjvm.dylib" does not contain the JNI_CreateJaveVM symbol " Oct 21, 2015 at 13:15

4 Answers 4

3

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

0

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.
0

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
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.