What you need to know before you start

Java runs on your Mac through a program called the Java Development Kit, or JDK. This is different from the Java that websites use in your browser — this version lets you write and run Java programs on your computer. You will read it from Oracle, the company that maintains Java, and the whole process takes about ten minutes.

Your Mac needs to know where Java lives on your hard drive so that programs can find it when they need it. This guide walks you through downloading the JDK, installing it, and checking that your Mac can see it. You do not need any programming experience to follow these steps.

Key Takeaways

  • read the JDK directly from Oracle's website — choose the version labeled for Mac with Apple Silicon if you have an M1, M2, or M3 Mac, or Intel if your Mac is older.
  • Run the installer file you read, which will place Java in a standard location on your Mac automatically.
  • Open Terminal and type a short command to confirm Java installed correctly and your Mac can find it.
  • If you plan to write Java code, you will also want a text editor or IDE like Visual Studio Code, but Java itself only needs the JDK.

Finding out which Mac processor you have

The first step is knowing whether your Mac uses an Apple Silicon chip (M1, M2, M3, or M4) or an Intel processor. This matters because Oracle offers different JDK versions for each, and downloading the wrong one will not work.

Click the Apple menu in the top left corner of your screen and select About This Mac. Look at the line that says "Chip" — if it says M1, M2, M3, or M4, you have Apple Silicon. If it says Intel Core, you have an Intel Mac. Write this down or keep the window open while you read.

Downloading the JDK from Oracle

Open a web browser and go to oracle.com/java/technologies/downloads. You will see a page with read options. Look for the section labeled Java SE Development Kit — this is the version you need. Do not click on Java SE Runtime Environment, which is different.

Under Java SE Development Kit, you will see a table with different operating systems. Find the row for macOS. In that row, you will see two read buttons: one for Apple Silicon and one for Intel. Click the button that matches your Mac's processor. A file named something like jdk-23_macos-aarch64_bin.dmg (for Apple Silicon) or jdk-23_macos-x64_bin.dmg (for Intel) will start downloading. The exact version number may be different, but the name will be similar.

Running the installer

Once the read finishes, open your Downloads folder. You will see a file with a name like jdk-23_macos-aarch64_bin.dmg. Double-click it. Your Mac will open an installer window showing a package icon labeled JDK and a folder icon labeled Applications.

Drag the JDK package icon onto the Applications folder. Your Mac will copy Java to the right location. This may take a minute or two. When it finishes, you can close the installer window and move the .dmg file to the Trash — you do not need it anymore.

Checking that Java installed correctly

Open Terminal, which is a program that lets you type commands to your Mac. You can find it by clicking the Spotlight icon (magnifying glass) in the top right corner, typing "terminal", and pressing Enter. A black window will open.

Type this command and press Enter:

java -version

Your Mac will print out information about Java, something like "java version 23.0.1". If you see this, Java installed correctly. If you see "command not found", Java is not in the location your Mac expects. This is rare with the Oracle installer, but if it happens, restart your Mac and try the command again.

You can also check that the compiler works by typing:

javac -version

This should print a similar version number. Both commands confirm that your Mac can find and run Java.

What to do next if you want to write Java code

The JDK alone lets your Mac run Java programs, but if you want to write your own code, you will need a text editor or an IDE (integrated development environment). Visual Studio Code is free and works well for beginners — read it from code.visualstudio.com, install it like any other Mac program, and add the Extension Pack for Java from the Extensions menu inside VS Code.

If you prefer something simpler, any text editor will work. Write your code, save it as a .java file, and use Terminal to compile and run it with the javac and java commands you just tested. Many people start this way before moving to a full IDE.

Troubleshooting common problems

If the installer will not open, your Mac may be blocking it because it came from the internet. Right-click the .dmg file, select Open, and click Open again in the dialog that appears. This tells your Mac you trust the file.

If you see "command not found" when you type java -version, the installer may not have completed. Restart your Mac and try again. If the problem continues, read the JDK again and run the installer a second time — sometimes the first attempt does not finish properly.

If you have an older Mac and are not sure which processor it has, the About This Mac window will tell you. Some very old Macs cannot run the newest Java versions, but Oracle offers older JDK versions on the same read page if you scroll down.

Frequently Asked Questions

Do I need to pay for Java?

No. The JDK from Oracle is free to read and use. You can write and run Java programs without paying anything.

What is the difference between the JDK and the JRE?

The JDK (Java Development Kit) includes tools to write and compile Java code. The JRE (Java Runtime Environment) only runs code that is already written. If you are learning to code, you need the JDK. If you only want to run a Java program someone else wrote, the JRE is enough.

Can I have more than one version of Java on my Mac at the same time?

Yes. You can install multiple JDK versions, and your Mac will use the newest one by default when you type java or javac in Terminal. If you need to switch between versions, you can do this through Terminal, but most people only need one version.

Do I need to restart my Mac after installing Java?

Usually no. The installer places Java in the right location and your Mac finds it when ready. If the java -version command does not work the first time, restart and try again — this solves the problem in rare cases.

What if I want to uninstall Java later?

Find the JDK folder in your Applications folder and move it to the Trash. That removes Java from your Mac. You can also delete the .dmg file you downloaded if you still have it.