Tutorials  /  JavaScript

Java Installation on MacBook M1

Ccentron Redaktion · May 2024 ·2 min read ·JavaScript, Tutorial

Encountering the 'Bad CPU type in executable' error during Java installation on your MacBook Air M1? We'll show you how to effortlessly resolve this issue.

Common Error

Due to the ARM64 architecture of Apple's new M1 chip, you might receive this error message when attempting to run the command "java -version":

Code
-bash: ./java: Bad CPU type in executable

The issue arises because the downloaded OpenJDK binary files are designed for the x64 architecture – an architecture commonly used in Intel processors, and thus not compatible with the new M1 chip.

VM

Matching infrastructure at centron

Node applications need somewhere to run: ccloud³ VMs with full root access from €3.12 per month – or as a managed server if you would rather not run it yourself. Rent a cloud server →

Solution: Find an ARM64-Compatible OpenJDK Version

To solve the problem, you need to use an OpenJDK version that is compatible with the ARM 64-bit architecture. We recommend Azul Zulu OpenJDK builds, which also provide builds for the ARM 64-bit architecture.

After downloading and extracting the appropriate Tar archive, you can run the Java command without any problems:

Console
 $ curl -O https://cdn.azul.com/zulu/bin/zulu16.30.19-ca-jdk16.0.1-macosx_aarch64.tar.gz
$ tar -xvf zulu16.30.19-ca-jdk16.0.1-macosx_aarch64.tar.gz 
$ cd zulu16.30.19-ca-jdk16.0.1-macosx_aarch64/bin
$ ./java -version

The result should now read as follows:

Code
 openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment Zulu16.30+19-CA (build 16.0.1+9)
OpenJDK 64-Bit Server VM Zulu16.30+19-CA (build 16.0.1+9, mixed mode)

Additional Note: Rosetta 2

After successfully installing Java, "Rosetta 2" runs in the background. This small application enables the execution of software originally developed for the Intel x64 architecture on Apple chip Macs. For more information, please refer to the Apple Support thread.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie JavaScript
Teilen
Noch offene Fragen?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

War dieses Tutorial hilfreich?

Your answer is stored anonymously and helps us improve our tutorials.

Kommentare

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren