Javier Javier - 1 year ago 38
Java Question

MacOSX 10.11.4: which java version is in use

I am aware this might look duplicated, but I don't seem to find the answer that I am seeking (perhaps is too trivial).

I just downloaded java from the oracle site and I read this:

$java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

Then I added this to my .bash_profile file:

# Java
export JAVA_HOME="`/usr/libexec/java_home -v 1.8`"

so that:

$ echo $JAVA_HOME

So far so good.

Now when I type:

$ which java

Which I think is the default installation (?, I really have no experience in Java)

At this stage, I don't know if I have to simlink:

sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java /usr/bin

or if the simlink was establish during the java installation. I am going to start installing a series of things that depend on java, so I would like to make sure I understand this before moving on.



What you've done will work. From my system:

$ /usr/bin/java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

It uses the java_home command you used, which depends on the Java part of the System Preferences application. So if somehow you have the "wrong" version in use, you can fix it there. But by default, it seems in my experience to use the latest version (man java_home doesn't really say).