Java is an optional package on the latest versions of macOS.
Yet once installed it appears like the JAVA_HOME environment variable is not set properly.
Java is an optional package on the latest versions of macOS.
Yet once installed it appears like the JAVA_HOME environment variable is not set properly.
My approach is:
.bashrc
This makes it very easy to switch between J6 and J7
for mac user . java 8 should add
java 6 :
ref :http://qiita.com/seri_k/items/e978c1339ce51f13e297
I'm using Fish shell on High Sierra 10.13.4 and installed Java via Brew.
It's not automatically set up so to set it correctly on my system I run:
None of the above answers helped me. I suppose all the answers are for older
OS X
For OS X Yosemite 10.10, follow these steps
Use your favorite text editor to open:
~/.bash_profile
Add the following line in the file and save it ( : followed by "x" for vim):
Then in the terminal type the following two commands to see output:
In the second line, you are updating the contents of
.bash_profile
file.For Mac OS X 10.9 I installed the latest version of JRE from Oracle and then reset the JAVA_HOME to /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home.
I am sure there is a better way but got me up and running.
hughsmac:~ hbrien$ echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
Update for Java 9 and some neat alias.
In
.bash_profile
:Note, that for the latest version it is
9
and not1.9
.Set active Java:
Some additional alias to switch between the different versions:
Test in terminal:
EDIT: Update for Java 10