2

TLDR; Why does brew/cask (or maybe even the native installer) install multiple executables for java?

System Data:

MacOS 10.13 / High Sierra

I am setting up a new dev machine and before installing java ran the following command: java and was told that no binary could be found.

From here I ran brew cask install java. At this point java became executable and running which java provided me a path at usr/bin/java. This location unsurprisingly turns out to be a link to

/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

Out of curiosity I ran: /usr/libexec/java_home which returned:

/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home

I believe that is the typical location for the JAVA_HOME environment variable. However, when looking at the path which the java bin points to you will notice that the location are different. JAVA_HOME/bin points to a location in /Library while which java points to a location in System/Library I understand that there is a general rule in Mac computing that says that /System resources are basic machine settings that shouldn't be monkeyed with and that /Library resources are for user installed and managed software, but I do not understand why I would have the exact same executable stored in two places.

My question is, why is the same software installed at two different places and why would JAVA_HOME/bin point to one binary while which java would point to another?


Resources I Used Before Asking:

what does mac os /Library folder store?

Where is Oracle's (Sun's) JDK/JRE installed on Mac OS X 10.8 Mountain Lion?

mattc41190
  • 31
  • 6
  • My guess - not being a Mac guy but having had to deal with this on a Mac before - is that this is how Macs have to be configured to run with Java. It's a royal pain in the neck. – Makoto Jun 03 '18 at 23:11
  • 2
    Read this blog post: http://mattshomepage.com/articles/2016/May/22/java_home_mac_os_x/ – Naveen Kumar Jun 04 '18 at 02:11
  • 1
    You question could be possible duplicate of https://stackoverflow.com/questions/15120745/understanding-oracles-java-on-mac/15133344 – Naveen Kumar Jun 04 '18 at 02:12
  • @NaveenKumar Thank you so much. This is totally a duplicate your second link answered my question. – mattc41190 Jun 04 '18 at 12:52

1 Answers1

0

This question is a duplicate and the answer comes from user bdash who deserves all credit for answering in a full and clear manner. Thanks to Naveen Kumar who provided this pointer. For full answer go to:

Understanding Oracle's Java on Mac

The short answer for folks coming to this page from google is that the items in /System/Library are stubs and not the real java executable. The true location for the JDK is the one exposed by /usr/libexec/java_home.

mattc41190
  • 31
  • 6