Where is Java Installed on Mac OS X?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
When you install Java on macOS, the system places the Java Runtime Environment (JRE) and/or the Java Development Kit (JDK) in specific locations. Understanding these locations can be essential especially for developers who need to configure the JAVA_HOME environment variable or for troubleshooting Java-related issues.
Overview of Java JDK and JRE Installations on MacOS
JDK (Java Development Kit)
The JDK is a software development environment used for developing Java applications and applets. It includes the JRE, an interpreter/loader (Java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc) and other tools needed in Java development.
JRE (Java Runtime Environment)
The JRE provides the libraries, Java Virtual Machine (JVM), and other components to run applications written in Java. It does not include development tools like the compiler or debugger.
Installation Locations
Java 8 and Below
For Java versions 8 and below, Apple provided its own version of Java. However, from Java 9, Oracle and other vendors (like AdoptOpenJDK) have provided Java for macOS. For these older versions, the typical installation paths are as follows:
- JRE:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home - JDK:
/Library/Java/JavaVirtualMachines/<jdk version>.jdk/Contents/Home
Java 9 and Above
From Java 9 onwards, the JDK or JRE is generally installed in the following locations:
- JDK:
/Library/Java/JavaVirtualMachines/<jdk version>.jdk/Contents/Home - JRE: Note that from JDK 11, the standalone JRE was deprecated and no longer distributed. The JRE is now part of the JDK.
Setting Up JAVA_HOME
The JAVA_HOME environment variable points to the JDK installation directory and is used by many Java-based applications to determine the Java installation location.
To set JAVA_HOME on macOS, you can add the following line to your shell configuration file (like .bash_profile, .bashrc, or .zprofile depending on the shell you use):
Where "version" is the version of Java you want to set as default, for example, 1.8. This command uses the macOS utility java_home to dynamically determine the JDK path for the specified version.
How to Verify Your Java Installation
To check which version of Java is installed, and which version JAVA_HOME is pointing to, you can use:
This will display the version of Java that is currently set as default and print the path that JAVA_HOME is pointing to.
Common Issues and Solutions
Here are a few common issues related to Java installations on macOS:
- Multiple Java versions: Managing multiple Java versions can be confusing. Tools like jEnv can help in managing and switching between different Java environments.
- JAVA_HOME not set: Some tools and applications require
JAVA_HOMEto be set. Always ensure it is correctly set in your shell configuration. - Java applets not working in browsers: Most modern browsers do not support Java applets due to security concerns. Java Web Start is also deprecated.
Summary Table
| Component | Java 8 and Below (Legacy) | Java 9 and Above |
| JDK | /Library/Java/JavaVirtualMachines/<jdk version>.jdk/Contents/Home | /Library/Java/JavaVirtualMachines/<jdk version>.jdk/Contents/Home |
| JRE | /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home | Integrated with JDK |
Setting JAVA_HOME | export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) | export JAVA_HOME=$(/usr/libexec/java_home -v version) |
In conclusion, the installation paths of Java on macOS have evolved, particularly from Java 9 onwards. Understanding these paths, how to configure JAVA_HOME, and knowledge of common issues can help in effectively managing Java installations on macOS.
Related reading
- Where is Java's Array indexOf?
- Where is the application.properties file in a Spring Boot project?
- Where is the Java SDK folder in my computer? Ubuntu 12.04
- Where is the Keytool application?
- Where to add .ebextensions in a WAR?
- Where to get UTF-8 string literal in Java?
- Where to put Bean in Spring Boot?
- Where to put static files such as CSS in a spring-boot project?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.