Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java/JDK for the Apple M1 chip

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?

like image 278
Thar Avatar asked Oct 15 '22 11:10

Thar


People also ask

Does Java JDK work on Mac M1?

The brew formula for openjdk is also installing a compatible Apple M1 JDK build. For managing different Java versions, sdkman or jEnv is an excellent option. For those lucky developers that have the chance to work and experiment with the GraalVM, the support for Apple M1 has also landed.

Which JDK is best for Mac M1?

Open JDK 17 for Apple M1 Macs Download "macOS / AArch64" version. OpenJDK is what IntegrityChecker Java has long used on Intel Macs.

Is Java compatible with Apple silicon?

You can run Java for Intel Macs on Apple Silicon (ARM, Aarch64) via Rosetta 2. But for maximum performance, obtain an implementation of Java 8 built for Apple Silicon Macs.

Is there any support for Java on the Mac M1 chip?

Java is not an Apple product, best you ask the app developer on their website/forum for support. When is Java going to be available for the Mac M1 Chip ? Several websites not really working with this computer because no Java script.

What JDK version of JDK supports M1?

if no then what I do next? As of January 2022 JDK 17 is the only release which supports M1: If you want to run a lower version you might want to search for other vendors.

Does OpenJDK 17 from Oracle support Apple M1 chip?

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.

Does Java run on the Apple-Silicon M1?

On the Apple-silicon M1, its code would be pre-translated by Rosetta into M1-code before execution, and cached while java is active. There have been no pervasive reports of issues with java and Apple-Silicon M1 processors posted here.


3 Answers

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.

like image 134
tresf Avatar answered Oct 17 '22 02:10

tresf


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.
like image 121
rzwitserloot Avatar answered Oct 17 '22 03:10

rzwitserloot


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.

like image 49
Ming-Yee Iu Avatar answered Oct 17 '22 03:10

Ming-Yee Iu