288

Will there need to be a special release of OpenJDK to support the new Apple Silicon chips?

I see that there are currently downloads of the JDK for macOS/OS X, but these seem to only be for x86 processors. Is that correct? If so, where can I download a version of OpenJDK for the M1?

3
  • 4
    I followed the youtube video for the JDK installation, youtube.com/watch?v=pZjGom2qTEA. It is working.
    – jrh
    Commented Dec 24, 2020 at 18:54
  • 8
    Native Apple/Arm64 versions are now available on brew, so you should be able to just do brew install java, provided you install brew natively without using Rosetta 2. Commented Jan 17, 2022 at 17:24
  • medium.com/@kirebyte/… works for me. Commented Oct 4, 2022 at 7:17

16 Answers 16

201

A command line approach (thanks to the Homebrew team and the hard work of @vladimir-kempik and other openjdk contributors on the JEP-391 branch)

# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install OpenJDK
brew install openjdk

Verify it's installed:

$(brew --prefix openjdk)/bin/java --version

Verify it's for the arm64 hardware:

file $(brew --prefix openjdk)/bin/java     
# /opt/homebrew/opt/openjdk/bin/java: Mach-O 64-bit executable arm64

Note: To install openjdk system-wide, follow the on-screen instructions provided by Homebrew.

13
  • 19
    this also works for java 11 without any problem brew install openjdk@11 and file $(brew --prefix openjdk@11)/bin/java - Apple MacBook Pro 2021 - M1 Pro (10 Cores) - using homebrew is for me the preferable option over other approaches
    – flohall
    Commented Dec 9, 2021 at 10:35
  • 4
    OpenJDK 17 is the first java version officially supporting the M1 architecture Commented Jan 6, 2022 at 19:55
  • 1
    $(brew --prefix openjdk)/bin/java --version. this works but java --version does not work... I guess I need to set the java home is it?
    – MrSham
    Commented Jan 8, 2022 at 4:38
  • 17
    @JustinFuruness if JAVA_HOME is a hard requirement, you can do export JAVA_HOME="$(brew --prefix openjdk)/libexec/openjdk.jdk/Contents/Home" although brew info openjdk contains instructions for configuring the system to find it, quoting: For the system Java wrappers to find this JDK, symlink it with... (the exact command is specific to your system, printed by Homebrew).
    – tresf
    Commented Jan 28, 2022 at 3:10
  • 1
    @tresf thank you, I spent the last 3 hours chasing my tail. your comment for how to add JAVA_HOME finally solved it for me
    – Dan Horton
    Commented Dec 20, 2022 at 9:25
126

Yes.

On this page: AdoptOpenJDK Latest Releases you can select 'macOS' from the 'Operating System' dropdown, and then from 'Architecture', it's currently only x64, but soonish there should be AArch64 or ARM64 (those are usually the shortcodes for 64-bit ARM). Possibly, as Apple no doubt has a bunch of extensions built into their M1 designs, and Apple gets its own.

If you instead leave Operation System on 'any', you'll note aarch64 is in there, and this gets you to a Linux release for ARM processors. That (probably) won't run on macOS on M1 hardware, but that's 95% of the work already done.

So: It's not there yet, but note that JDKs for ARM have been available for more than decade, and whilst JDK 15 has dropped support for a bunch of exotic OS/architecture combinations (such as Solaris), ARM development has always remained at least partially relevant (even if so far it's mostly an Oracle commercial license offering). That is to say: It should not be a herculean effort to create an adoptopenjdk release that runs on M1s natively, so presumably, it will happen. But, it's an open source effort, so if you're anxious, by all means, read up and contribute :)

Apple has not given any details on this architecture whatsoever until November 10th 2020, unless you bought a development kit box for it (a Mac Mini with an A14 chip, which isn't an M1 chip, but close enough I guess), and signed a big NDA.

As a rule, open source projects will run as fast as possible in the opposite direction if you wave an NDA around, so if you dislike this state of affairs, I don't think it's wise to complain to adoptopenjdk or other packagers and open source projects about it :)

Fortunately, now it's out, and an NDA is no longer required. My assumption is that the ARM branch of the OpenJDK source code + the macOS bits that already exist for the macOS x64 release can be combined rather easily once someone with some familiarity with the OpenJDK source code has an M1-based macOS system to test it on, which should mean an adoptopenjdk macos-aarch64 release should be here within the month.

But, open source. You didn't pay them, you have no contract, and they don't owe it to you. Donate to the effort or contribute a pull request if you want it to go faster.

UPDATE:

  • Azul's M1 OpenJDK builds
  • Microsoft's (yes, really) GitHub source repo for an early access OpenJDK16 build for macOS on AArch64. Note that Microsoft's been working on the OpenJDK branch of AArch64 (for ARM-based Windows 10) for a while, which goes back to: A lot of the hard work was already done.
13
  • 1
    Thank you! , FYI bugs.openjdk.java.net/browse/JDK-8251280
    – Thar
    Commented Nov 11, 2020 at 14:21
  • 3
    Running gradle didn't work on Microsoft's preview build. Reported it here github.com/openjdk/aarch64-port/issues/8 Commented Nov 25, 2020 at 5:49
  • 3
    This post says "soonish", but it's been 9 months and the Adopt links are no more helpful than they were when they were originally posted. The aarch64 explanation is helpful, since it's not obvious to most M1 users that these terms are synonymous, but that first link is still not helpful and should be edited out until the Adoptium team can produce M1 artifacts.
    – tresf
    Commented Aug 17, 2021 at 16:07
  • 3
    Please note that the project OpenJDK has moved to Eclipse Fondation and now the new website is : https://adoptium.net
    – jpmottin
    Commented Dec 3, 2021 at 19:14
  • 3
    "Soonish" is finally here. The Adoptium project recently published their first M1 release for Java 17. adoptium.net/….
    – tresf
    Commented Dec 17, 2021 at 3:05
53

Azul is offering macOS ARM builds of OpenJDK on their website in the Downloads section. I haven’t tried them out yet though, but Azul have been long-time JDK developers.

Once you unpack the Azul JDK, you have to rummage around inside of it until you find the zulu-11.jdk directory (assuming you've downloaded JDK 11), which you then copy to /Library/Java/JavaVirtualMachines.

2
  • 7
    i downloaded their .dmg and it just worked -- no copying around needed
    – Renaud
    Commented Feb 6, 2021 at 0:09
  • *.dmg version requires no copying, you might downloaded the *.zip one
    – omzer
    Commented Feb 12, 2021 at 14:27
51
brew install openjdk

In my case, after installing OpenJDK successfully on MacBook Air (M1), the java command still did not work. I fixed it by

brew info openjdk

Then there is a command like

For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

Execute this command and the java command works.

26

You can install the Java JDK using sdkman (see sdkman install):

vim ~/.sdkman/etc/config

Set sdkman_rosetta2_compatible=false (see sdkman config)

After that, you will see a list of compatible with M1 JDKs:

sdk list java

================================================================================
Available Java Versions
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 Azul Zulu     |     | 16.0.1       | zulu    |            | 16.0.1-zulu
               |     | 11.0.11      | zulu    |            | 11.0.11-zulu
               |     | 8.0.292      | zulu    |            | 8.0.292-zulu
 BellSoft      |     | 16.0.1       | librca  |            | 16.0.1-librca
               |     | 11.0.11      | librca  |            | 11.0.11-librca
               |     | 8.0.292      | librca  |            | 8.0.292-librca
 Java.net      |     | 18.ea.3      | open    |            | 18.ea.3-open
               |     | 18.ea.2      | open    |            | 18.ea.2-open
               |     | 18.ea.1      | open    |            | 18.ea.1-open
               |     | 17.ea.28     | open    |            | 17.ea.28-open
               |     | 17.ea.27     | open    |            | 17.ea.27-open
               |     | 17.ea.26     | open    |            | 17.ea.26-open
               |     | 17.ea.25     | open    |            | 17.ea.25-open
================================================================================

Choose one and install it using the command sdk install java IDENTIFIER, i.e.:

sdk install java 8.0.292-zulu

3
  • "compatbile" (in sdkman_rosetta2_compatbile) looks like a misspelling (true typo) of "compatible". Are you sure it is spelled like that? Commented Nov 15, 2021 at 22:01
  • @PeterMortensen you are right, this was a typo in my answer, I fix it Commented Nov 16, 2021 at 13:03
  • 2
    don't forget to update JAVA_HOME, eg export JAVA_HOME=/Users/<username>/.sdkman/candidates/java/current
    – Lingster
    Commented Jun 30, 2022 at 5:11
22

Now, OpenJDK 17 from Oracle supports the Apple M1 chip. The status of the JEP 391 is closed & delivered.

You can download the free, macOS/AArch64 open-source build of the JDK, version 17 from the official website.

3
  • I tried the OpenJDK18 - now at jdk.java.net/18 The when I navigated in Terminal to the Contents/home/bin folder and typed java --version I got Unable to locate Java Runtime. So it's not the best answer. There must be another part to the jigsaw to get the JRE on a new Mac M1.
    – JGFMK
    Commented May 10, 2022 at 11:05
  • I just experimented with it now. If you try to execute java --version in the Contents/home/bin folder, it will execute the system default java cli version(if you already have java in your system). From that folder try to cd .. to Contents/home and execute bin/java --version it should pick up the the JRE version you just installed. Commented May 10, 2022 at 13:07
  • I ended up using another option jdk-18_macos-aarch64_bin.dmg was what worked for me in the end, per the @Waqas answer. It was a brand new MacBook Pro M1 Max. So no java on the machine beforehand.
    – JGFMK
    Commented May 10, 2022 at 13:48
16

I am successfully developing Java applications on the new Apple M1 Chip with Azul OpenJDK and NetBeans.

Configuration:

  • zulu16.0.65-ea-jdk16.0.0-ea.24-macos_aarch64
  • NetBeans 12.1 and Maven.
7
  • Hi can I ask if Jenkins is working fine and how did you get the support for maven? Thanks
    – L m
    Commented Dec 3, 2020 at 18:34
  • 1
    Hi, It is still early days, and there are many open-source packages that do not support the chip. I have not installed Jenkins at present, and the maven packages I have tried so far have presented no issue, no doubt there will be some that will. I am at present like most people exploring only;
    – user14679771
    Commented Dec 4, 2020 at 21:37
  • Are you using docker? I cannot find an Azul OpenJDK docker image for arm64.
    – jenglert
    Commented Feb 10, 2021 at 23:09
  • I have not used Docker for the development environment.
    – user14679771
    Commented Feb 12, 2021 at 2:00
  • Once I install the Azul OpenJDK, how can I run a jnlp file? Seems like it's not possible, since there's no javaws binary?
    – genevish
    Commented Mar 4, 2021 at 18:28
16

The latest build for Mac M1's are available now

https://www.oracle.com/java/technologies/downloads/#jdk18-mac

enter image description here

7

Please go to the Azul site and download the .dmg file:

https://www.azul.com/downloads/zulu-community/?os=macos&architecture=arm-64-bit&package=jdk

This will be placed in a library and once IntelliJ IDEA identifies it, it should be good to run.

7

I've tried the Azul JDK 8.

I just wanted to say that, while the Azul JDK works natively on Apple M1 and its speed is great, there are still issues. Especially when some Java code needs to call C++ code.

For example, I am a big data developer. And I started using the Azul JDK for my development workflow. But I noticed that certain tests started failing after the switch. For example, when the test writes to a Parquet/Avro file, it fails. I think that is because there are some native things written in C++ for Parquet/Avro, and they are not compiled for M1.

For this specific reason I am forced to use the non-M1 JDK, which is slow. There are no issues there.

Here's an example of the error that I get with Azul that I don't get with non-M1 JDKs:

- convert Base64 JSON back to rpo Avro *** FAILED ***
  org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 10.0 failed 1 times, most recent failure: Lost task 0.0 in stage 10.0 (TID 14, localhost, executor driver): org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=Mac and os.arch=aarch64
        at org.xerial.snappy.SnappyLoader.findNativeLibrary(SnappyLoader.java:331)
        at org.xerial.snappy.SnappyLoader.loadNativeLibrary(SnappyLoader.java:171)
        at org.xerial.snappy.SnappyLoader.load(SnappyLoader.java:152)
        at org.xerial.snappy.Snappy.<clinit>(Snappy.java:47)
        at org.apache.avro.file.SnappyCodec.compress(SnappyCodec.java:43)
        at org.apache.avro.file.DataFileStream$DataBlock.compressUsing(DataFileStream.java:358)
        at org.apache.avro.file.DataFileWriter.writeBlock(DataFileWriter.java:382)
        at org.apache.avro.file.DataFileWriter.sync(DataFileWriter.java:401)
        at org.apache.avro.file.DataFileWriter.flush(DataFileWriter.java:410)
        at org.apache.avro.file.DataFileWriter.close(DataFileWriter.java:433)
        at org.apache.avro.mapred.AvroOutputFormat$1.close(AvroOutputFormat.java:170)
        at org.apache.spark.internal.io.SparkHadoopWriter.close(SparkHadoopWriter.scala:101)
        at org.apache.spark.rdd.PairRDDFunctions$$anonfun$saveAsHadoopDataset$1$$anonfun$12$$anonfun$apply$5.apply$mcV$sp(PairRDDFunctions.scala:1145)
        at org.apache.spark.util.Utils$.tryWithSafeFinallyAndFailureCallbacks(Utils.scala:1393)
        at org.apache.spark.rdd.PairRDDFunctions$$anonfun$saveAsHadoopDataset$1$$anonfun$12.apply(PairRDDFunctions.scala:1145)
        at org.apache.spark.rdd.PairRDDFunctions$$anonfun$saveAsHadoopDataset$1$$anonfun$12.apply(PairRDDFunctions.scala:1125)
        at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
        at org.apache.spark.scheduler.Task.run(Task.scala:108)
        at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:335)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

Driver stacktrace:
  at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1499)
  at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1487)
  at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1486)
  at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
  at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
  at org.apache.spark.scheduler.DAGScheduler.abortStage(DAGScheduler.scala:1486)
  at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:814)
  at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:814)
  at scala.Option.foreach(Option.scala:257)
  at org.apache.spark.scheduler.DAGScheduler.handleTaskSetFailed(DAGScheduler.scala:814)
  ...
  Cause: org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=Mac and os.arch=aarch64
  at org.xerial.snappy.SnappyLoader.findNativeLibrary(SnappyLoader.java:331)
  at org.xerial.snappy.SnappyLoader.loadNativeLibrary(SnappyLoader.java:171)
  at org.xerial.snappy.SnappyLoader.load(SnappyLoader.java:152)
  at org.xerial.snappy.Snappy.<clinit>(Snappy.java:47)
  at org.apache.avro.file.SnappyCodec.compress(SnappyCodec.java:43)
  at org.apache.avro.file.DataFileStream$DataBlock.compressUsing(DataFileStream.java:358)
  at org.apache.avro.file.DataFileWriter.writeBlock(DataFileWriter.java:382)
  at org.apache.avro.file.DataFileWriter.sync(DataFileWriter.java:401)
  at org.apache.avro.file.DataFileWriter.flush(DataFileWriter.java:410)
  at org.apache.avro.file.DataFileWriter.close(DataFileWriter.java:433)

As you can see, it says: Cause: org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=Mac and os.arch=aarch64

I googled this issue and they said that the native library is compiled for a later version of Spark, unfortunately.

This frustrated me tremendously, and I want a Windows laptop now, LOL. Running an Intel JDK on the M1 chip can be slow at times, and I don't want that.

Be careful!

Update: They released new versions of their libraries with support for M1, I updated them in the projects and everything works, thank God. Sometimes these "native code errors" manifest themselves with different exceptions and this is additional P.I.T.A. that I have to deal with while my colleagues on windows laptops don't need to deal with it. The errors can be a bit unclear sometimes, but if you see something about native code in the error log, or words like "jna" or "jni", then it's an M1 chip problem.

6
  • If a particular lib has native bindings and does not offer an aarch64 (ARM64) port, you should file a bug report with them. Java developers need to work with the projects in which they are reliant upon to ensure ARM64 support is added, especially if you rely on a volunteer-led project. So I'd argue don't "be careful", but rather "be patient", or better... "be proactive" and send those projects pull requests, or in your case, update your library.
    – tresf
    Commented Jun 26, 2021 at 16:07
  • And you want me to do this for every single library that has this issue? People should really be careful with using this jdk, because they can waste hours or even days trying to understand why their project isn't getting built and googling the errors that come up from this. It's easier to just use an intel JDK. Commented Aug 17, 2021 at 9:51
  • 2
    Yes, it's absolutely the obligation of the community which relies on an open source library to help file bug reports and track what works. That's how open source works. A user or developer finds out what's broken, gets involved, lets the right people know and offer to help. In the specific case of your error a link was provided to a fix. It would benefit others to document this process. Updating this dependency may not be obvious and will differ between projects, but documenting this for others will help progress the community forward. Open source is a crowd-sourced effort. :/
    – tresf
    Commented Aug 17, 2021 at 15:52
  • in your specific use-case, a good starting point is to ask a question (e.g. on stack overflow) on how to get your tool working natively with M1 CPUs and cross-link this bug report. Although we may not completely understand the underpinnings of the tools we rely upon, it's very important to set expectations for ourselves and others when it comes to open source libraries. The M1 CPU has exposed many native projects that need updating. Fortunately, most have already been patched, but getting those patches into our projects is a great reason to ask questions on sites like this. :)
    – tresf
    Commented Aug 17, 2021 at 15:57
  • if someone cares, I got the same problem for kafka-clients:3.0.0. I excluded the snappy version that comes with that, and upgraded to the latest one - that has M1 arm support
    – Eugene
    Commented Jan 20, 2022 at 10:15
7

I followed the below steps and I was able to successfully run JDK 16 on a MacBook Air (M1):

  1. Go to "Oracle.com"
  2. Go to ProductsSoftwareJava
  3. Click on "Download Java Now"
  4. Click on "JDK Download"
  5. Select "macOS Installer"
  6. Install JDK
  7. Try with any sample Java program and this should work for you.

I was able to install and successfully run this on my MacBook Air (M1).

3
6

You can download the Liberica JDK from:

https://bell-sw.com/pages/downloads/?os=macOS&architecture=ARM

In IntelliJ IDEA for M1, the JetBrains Runtime is also native (ARM64).

2
  • Example of path for the IDEA jre: /Users/o_o/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/211.7628.24/PyCharm.app/Contents/jbr/Contents/Home
    – Arnaud P
    Commented Jul 6, 2021 at 12:49
  • For those who need java 8 for ARM: bell-sw.com/pages/downloads/#/java-8-lts
    – ryenus
    Commented Jul 15, 2022 at 13:18
4

It's not just JEP-391.

There is a preview branch, https://github.com/openjdk/jdk-sandbox/tree/JEP-391-branch, one can build JDK 16 early-access (EA) using cross-compilation on Intel Mac or directly on ARM Mac. And it runs fine.

0
3

Microsoft and Azul appear to be prime movers on JEP 391 in combination with the Windows port (JEP 388). They have a separate GitHub repository that actually has an EA release for macOS-aarch64.

I am not sure what exact relationship is with the OpenJDK repository.

2

Simply use go to Java downloads and in the menu select tab "Java 18" and then tab "macOS". Download the Arm 64 DMG Installer.

You can verify whether it has worked or not by opening up the terminal and typing:

java -version
-2

Here are steps to install Oracle JDK 8 and run it from Rosetta - https://www.oracle.com/in/java/technologies/javase/javase-jdk8-downloads.html

  • Download the macOS x64 version
  • While attempting to install the package, you will receive a prompt to install Rosetta if it already doesn't exist
  • The rest of the installation steps are as any other package.

You can verify it has worked or not by opening up terminal and typing:

java -version
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.