Step by Step: Installing Java on Mac
Java is one of the most popular programming platforms used by developers around the world, if you just bought a new MacBook computer, this step by step tutorial may come handy. Here are the steps to install Java on your Mac computer:
Step 1 – Check Existing Version
If this a new MacBook then you should be able to skip this step, otherwise check if you already have Java installed. Open a terminal and type:
java -version
This will print the version if Java is already installed.
Step 2 – Download the Java Installer
If you don’t have Java or need to upgrade, go to Oracle’s website (https://www.oracle.com/uk/java/technologies/downloads/) and download the Java installer:
Make sure to select macOS as the platform. You will see two versions of the installer, one starts with ARM6 and the other is x64, if your MacBook has the latest Apple Silicon then you might want to try and download the ARM version, otherwise the x64 version should do. Select the .dmg file to start the download.
Step 3 – Run the Installer
Once downloaded, double click the .dmg file to open it. This will mount the disk image. Run the .pkg installer file to start the installation process.
Step 4 – Follow the Installation Wizard
Follow the on-screen instructions to install Java. Make sure to read the licensing terms before accepting them. The installer will copy Java files onto your system.
Step 5 – Set JAVA_HOME Environment Variable
After installation, you need to set the JAVA_HOME variable to point to the Java installation directory. Open a terminal window on your mac and then type/paste the following:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-version.jdk/Contents/Home
Replace jdk-version with the actual version number of the JDK you just downloaded.
Step 6 – Add Java to PATH
Finally, add Java binary path to the system PATH:
export PATH=$JAVA_HOME/bin:$PATH
Now Java is installed and ready to use! You can verify it by running java -version
.
That’s it! Let us know if you have any questions.