Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make Java 8 the default on a Mac? [duplicate]

Tags:

java

I have installed Java 8 on a Mac (OS 10.9.5) and it now appears in System Preferences. However, when I type the following in the command line:

java -version

it shows that I am using version 6:

java version "1.6.0_65"

How can I make version 8 the default?

like image 784
user2861089 Avatar asked Jan 26 '26 18:01

user2861089


1 Answers

You need to add this to the .bash_profiles file. It should be under the /User/yourUsername/ folder. if it is not there please create it.

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home
export PATH=${JAVA_HOME}:$PATH:

note you might have to change the path/version based on your machine

Step 1: Open terminal and navigate to User/yourUsername/ folder
Step 2: type vi .bash_profile and then hit enter
Step 3: hit 'I' so that it in insert mode (you can verify this by looking and the left bottom corner)
Step 4: type the above two lines whit appropriate path.
Step 5: hit esc key and the press ':wq' without the the ' (Your should see this getting type and bottom left corner) then hit enter

EDIT :


This should set up with what you need.

You can also do this approach :

In Terminal, navigate to the following location:

cd /System/Library/Frameworks/JavaVM.framework/Versions/

The CurrentJDK symlink in this directory was still pointing to an older Java version. To resolve this, remove the symlink and create a new one pointing to the new Java 7 JDK (you may need to use sudo to run these commands):

rm CurrentJDK
ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/ CurrentJDK

note you might have to change the path/version based on your machine

This is what it should be done to get rid of the error for unable to stat /etc/sudoers: Permission denied

ls -l /etc/sudoers.d/
sudo chown root:root /etc/sudoers.d/README
sudo chmod 440 /etc/sudoers.d/README
ls -ltr /etc | grep sudoers.d
sudo chown root:root /etc/sudoers.d
sudo chmod 755 /etc/sudoers.d

like image 144
StackFlowed Avatar answered Jan 28 '26 06:01

StackFlowed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!