Building Cloud Expertise with centron - Our Tutorials

Whether you are a beginner or an experienced professional, our practical tutorials provide you with the knowledge you need to make the most of our cloud services.

Java Installation on MacBook M1 without ‘Bad CPU type’ Error

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”:

 -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.

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:

 $ 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:

 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.

Start Your Free Trial with Our Cloud Services Today!

Ready to simplify your Java installation on MacBook M1? Sign up for our free trial and discover how our cloud solutions make it seamless to deploy and manage Java applications. Experience the power of cloud computing with enhanced compatibility and performance. Don't let system architecture hold you back—try our cloud services now and take your Java projects to the next level!

Try for free!