Java Development on Apple Silicon
By: Andrew J. Thom
Tags: Apple Silicon, Java, Software Development, Mac

About screen for IntelliJ IDEA showing it running natively on Apple Silicon

Update with Apple Silicon native Node from December 18, 2020 at the end of the article.

On December 15, I noticed that MacStadium had Apple M1-powered Mac minis available in their data centers. For a price of $99/month, you can rent an 8-core, 8GB memory, 256GB SSD equipped Mac. Being a curious Java engineer, I knew I had to give it a try. Here’s my experience.

First off, I’m a solo Java developer creating an internal software tool for a food manufacturing company. My main development environment is IntelliJ IDEA, and I use JDK8 and Kotlin 1.4. I also do frontend development for this application, which uses Webpack to do minification and all that jazz. All of this is built using a single Maven script to pack it all into a fat JAR that is easy to deploy to AWS. My current main development machine is a 27" iMac with an Intel Core i9 (10-core) and 64GB of RAM that I just bought in August after the last iMac refresh.

I knew there were going to be some bumps along the way trying to get this thing to build on an Apple Silicon Mac. Thanks to Azul, their Zulu builds of OpenJDK are already running on ARM (Java 8, 11, and 13 are available, along with an early access version of Java 16). Downloading the DMG, the installer put the JDK into the correct location and Java was up and running natively on ARM within a minute. Next was getting the build to run. Everything seemed to be going smoothly, until I got to the part where it tried to download the Node binary. Because it was detecting an ARM CPU, it was generating a download link for a Darwin ARM64 build of Node, which doesn’t exist. I found the plugin I use, frontend-maven-plugin, did some quick modification to the code to use the x64 binaries on Apple Silicon (and added a calendar event to remind me weekly to check for Apple Silicon native binaries so we can update the plugin again once they are available), submitted a pull request, and thankfully the developer accepted it and released a new version within hours. Thanks, Eirik!

And once I updated my Maven file to use the new version of the plugin, it all just worked. I ran the build and it flew. Coming from a 64GB, 10-core Mac, I expected the M1 machine to lag behind a bit in speed. But I sure was wrong. Running a production build, which includes full minification, takes usually around 1:40 on my iMac. So I was thinking it would take 2–2.5 minutes on the M1 Mac. But, to my surprise, the M1 Mac actually beat out the 10-core iMac, running a production build in 1:14. Now, looking back on it, we know that the M1 has ridiculous single-core performance based on benchmarks, and I should have realized that would make a difference. But I didn’t expect performance from a $700 Mac mini to equal the performance from my $4,500 iMac that has 8x the RAM of the Mac mini. I was very impressed. And then I remembered that the Node binary was the x64 version, meaning that part of this process is running through the Rosetta translation layer. So, I would expect this to get even faster once there are ARM builds of Node available for macOS. My reaction: wow.

As someone who uses IntelliJ, I was curious as to how it would run on Apple Silicon. I really wasn’t sure. After fiddling around with some settings to try and get the x64 version running on the Zulu JDK (without success, but I know that it can be done), I took a look at the YouTrack issue for JetBrains Runtime and its progress for getting it to run on Apple Silicon. I’ve checked this every so often over the last few months to see the progress, and I noticed that there are now builds for IntelliJ IDEA 2020.3 (both Ultimate and Community) available for testing from that YouTrack issue. I downloaded the Ultimate version, and on first launch, it gave me an error saying that JDK11 must be available. So, I went back to the Zulu JDK download page, downloaded JDK11, installed it, and launched IntelliJ and it worked. Perfectly. I opened up my project, hit the run button, and it all just worked. I was shocked. With less than an hour of work (not including the time waiting for the GitHub pull request to be accepted), I had my entire development environment running on Apple Silicon. Overall, a pretty painless process.

Now, of course, everyone’s experience will be different. As Theo Grey, co-founder of Wolfram Research, said on stage at WWDC in 2005 when talking about Apple’s transition to Intel, “Your mileage may vary.” This is a smaller project, and I have no idea how it’ll run with projects with millions of lines of code. But, Apple Silicon Macs have been shipping for less than a month, and based on my quick experience with one, I’d say it’s plausible that I could replace my $4,500 iMac with a $700 Mac mini for Java development. Of course, I’d need to do more testing to verify this. But if this is what Apple can do with the first generation of Apple Silicon Macs, I can’t wait to see what’s coming next.

UPDATE: I found that Node native for Apple Silicon is available on Homebrew. I installed that and it brought the Apple Silicon build down to 1:03, handily beating my 10-core 64GB iMac.

Note: I was not sponsored by MacStadium, nor did I receive any compensation or free services from them (or anyone else).