Setting up Java Development for Mac M1

Calendar Icon

Publish date:

September 14, 2022

Updated on:

June 13, 2024

Clock Icon

Read time:


Setting up Java Development for Mac M1


Apple's latest release of Mac devices, driven by the M-series of arm64 processors is proving to be highly popular amongst developers, designers, and enthusiasts. It's a technology that has had some initial teething troubles in finding and building the tools necessary for software development. During the initial launch phase, in particular, setting up Java development for Mac can come with a handful of pitfalls and traps that you might need to guard against.

Developing and testing Java applications on Apple's newest flagship devices is both entirely possible, and highly performant. It's a topic that will require a few small workarounds, some care in the initial setup, and a few insider tips and tricks gained through hard-won experience.

Our teams of top Java development companies are more than familiar with solving problems and challenges just like these when it comes to developing Java software. With decades of combined experience and unbeatable knowledge in specialist domains, these developers can build software and applications for your organization in no time at all.

Four developers at a conference table with laptop, notebooks, and tablet devices open in an active discussion.

Here, we take a look at how to set up and use a Java build environment on modern Apple devices. Starting with the tools and resources you need to develop Java for Mac, looking at the pitfalls to watch out for, and finding the solutions that will improve your Java development experience — we've created a complete and essential resource to guide you through the topic.

Java Development for Mac M1

In November 2020 Apple released the first machines in their Mac line-up to include Arm-based M1 processors. This move marked a departure from the Intel processors the company had been using since late 2006. This change in design is much more than swapping one type of processor for another.

The M1 chip differs from conventional processors as a complete SoC (system on a chip) solution. The M1 integrated CPU, GPU, memory, controllers, and a whole host of additional systems into a single unified chip.

The advantage of this approach is in allowing for exceptional performance, resource sharing, and a host of related solutions that take advantage of this technology to come in the near future. The short-term drawbacks, however, come primarily in the hardware and software compatibility issues that arise in changing from Intel's x64 architecture to Arm's aarch64 solution.

For developers, these compatibility issues are something that many haven't had to deal with for quite some time. For some, it will be the first time in their careers that this issue has ever come up in such a big way. Yet, despite being an initial nuisance of new technology this hurdle is one well worth overcoming to reach the performance advantages that the M1 can unlock. The first step to reaching these advantages is building the tools and technologies necessary to get there.

Installing Java for Mac

Install Java Development Tools

The first thing Java needs to begin developing for Mac is the JDK (Java development kit). Here, our usual approach would be to install the readily available openJDK tools on our machine. For the aarch64 architecture, we have to rely on one of the many available JDK vendors offering an aarch64 build of the OpenJDK not yet directly available. Luckily, there are several good options to choose from:

Each option is roughly equivalent for the purposes of building and getting started creating Java software for Mac. Simply download and install any one of these available options. There are no practical differences in the installation process compared to older mac, Linux, or Windows devices.

Setup the Environment

With Java installed on your system, we have all the ingredients in place to begin writing Java software. First, we have to put them together in the right order. The first step is finding out where Java has been installed and pointing our system to the right directory to retrieve the language tools and resources necessary for Java development tools to run.

Open the terminal and type:

  • /usr/libexec/java_home

Then press enter. This command will display the directory that Java has been installed to on your system. You want to copy the file path provided and edit either: .zshenv for Z Shell users, or .bashrc for Bash users.

If you don't yet know whether you're a Z Shell user or a Bash user you can type echo $SHELL and look for the output of either: /bin/bash, or /bin/zsh. Next, we're going to edit the environment variables by typing either:

  • vi ~/.zshenvor
  • vi ~/.bashrc

We're going to add the Java home path to this file and set up the system path variable to allow our machine to find it. Using jdk1.8.0_291.jdk this will look something like this:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home

export PATH=%JAVA_HOME/bin:$PATH

To exit vi, press escape then type wq (write and save), and then press enter.

Now if you open the terminal again and type Java -version it should show your version of Java recently installed.

Now that we know how to set up and configure Java manually, it's worth pointing out that there are some automated tools to help you set up and configure multiple versions of Java on your machine. These include:

Both are excellent tools that can save you a lot of time in the future after learning everything you need to know about how Java is installed and run on your machine.

Setup the IDE and Use Java

The final step in setting up Java on Mac is to install a suitable IDE to write code on your machine. Most providers have gotten around to producing an ARM build of their software today and for the rare exceptions that haven't then the emulated x64 version on Mac works without issue pretty much universally.

A woman is working in an IDE to write code on a Mac computer.

Having the knowledge and experience of troubleshooting JDK issues and understanding how the language works under the surface are invaluable skills that every Java developer should have at their disposal. These are also the kind of skills likely to feature in our tips to being a better Java developer guide alongside the other key skills and experience you should bring to the table.

Testing and Deployment of Java Code for Mac

One of the biggest impacts switching to aarch64 can have on developers is in integration testing and deployment. It can be a challenge to find Docker images with arm64 support, for example. In many cases, developers have to rely on emulating the environment to satisfy tests with results that are far less reliable than native support.

Teams will often have to build and share their docker images amongst themselves to support developers with aarm64 architecture. Within teams, these are the kinds of issues that rely on good communication, thorough documentation, and a productive working environment to maximize a group's potential. Our guide to working with remote Java developers has tips and solutions to help you make the most of your remote teams and create long-lasting processes.

Testing Issues with Java on Mac

Switching to an alternate architecture often means teams are required to overwrite Docker's default images with arm64 compatible alternatives. another way to circumvent these issues is to use cloud-based containers to run full suites of integration tests and cut down or temporarily disable the number of tests done locally.

These issues, however, are only temporary impacts of a new technology. We can expect more and more arm64 compatible images to be available soon as more versions of the M-series become available to consumers. Already, the challenges associated with testing and running Java code on mac are less significant than this time last year.

Emerging patterns in Java development are one of the best reasons to keep on top of the latest trends in hiring and managing Java developers in your teams.

Java Development for Mac M1

Resolving the initial issues of introducing Java to the latest Mac device is a significant technical hurdle to overcome. It's an issue that takes some time, patience, and perseverance — particularly when colleagues can be up and running in a flash. Yet, this is a technical hurdle that is getting less significant every day.

More and more software providers are now providing arm64 solutions and releasing software updates to work with Apple's latest flagship devices. In the next year or two, we can confidently predict that working with Java on Mac won't be any more complex or challenging than any other devices, and so guides like this won't even exist.

On the other side of the technical trade-off, the performance characteristics of modern architecture are already proving to be a worthwhile investment for developers. Using the latest architecture Java is capable of building and running faster on M-series chips that an equivalent x64 Mac machine. The step-change enabled by building while using Java development for Mac today is one that's only going to get bigger over time.


Q1. Can I develop Java on Mac?

Yes, you can develop Java on Mac whether your device is an intel-based Mac or an M1 or M2 Mac device. For the most part, there is little difference between deploying to an Intel-based Mac and any other Windows or Linux machine. For M1 and M2 Macs there are a couple of small changes to setting up the IDE and Java Development Kit that you should be aware of to ensure everything runs smoothly.

When looking for compatible software, you should look for solutions that work on aarch64 architecture natively. Today, more than two years after the release of the M1 chip, most companies offer an aarm64 version of their software. For the select few that don't, you can run most programs in an x64 emulator on Mac that creates an architecture-compatible version. Whether running natively on the M1s architecture on an x64 emulator, you should have very few issues developing Java software to run on your machine.

Q2. How do I get a Java Development Kit for Mac?

The OpenJDK is available for all intel-based macs produced in 2020 or earlier. For the more modern M1 and M2-based Macs, developers have to rely on vendor-produced OpenJDK releases to find an aarm64 compatible OpenJDK to run on their machine. Luckily there are several available including:

Any of these can be downloaded and run on an M-series Mac device in the same way that OpenJDK is run on any other machine. As the M-series architecture matures with the M2 chips being released in mid-2022, we can expect fewer compatibility issues between software and hardware. For developers, this should mean finally unlocking the performance capabilities of the M1 and M2 chips and making the most from hardware that has, until now, been limited by the software and resources that supports it.

Q3. How do I run a Java program on Mac?

Running a Java program on Mac is as simple as running on any other kind of hardware. If you've installed the OpenJDK for your system you should be able to verify it's working correctly by running 'java -version' in the terminal. If the version of Java you installed is showing as a result then you are ready to compile and run your Java program.

Open up a text editor and create a simple Java program.

public class HelloWorld {

public static void main(String args[]) {

System.out.println("Hello World!");



Save this file as ''. Using the terminal again, navigate to the folder you've saved helloWorld.Java to and run the command:

  • javac

This uses the Java compiler to turn your code into a program in the file helloWorld.class. This file is filled with Java byte code and can't be read but runs as a program on the computer instead. Use that file by running the command:

  • Java helloWorld

This will start a Java Virtual Machine, load the helloWorld class and execute its main method outputting "hello world!" as your first Java program.


Enjoyed the article?

Like it and let us know what you think, so we can create more content tailored to your interests.

Ian Deed

Linkedin Icon

Software developer, mobile application engineer, and writer helping companies to enhance their tech branding and improve the way they communicate with technical and non-technical audiences.

Leaning on years of experience and knowledge to understand technical communication that works from wordy jargon that doesn't.

More from this author

Join the community.