0

I just got a MacBook Pro with the new M1 chip. I'd like to use native Apple Silicon code wherever possible.

I have a Java-based command-line program running and I noticed that this java process in Activity Monitor is of type 'Intel'.

The process's path is /usr/bin/java, which is supposed to be a Universal binary:

$ file /usr/bin/java
/usr/bin/java: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/usr/bin/java (for architecture x86_64):    Mach-O 64-bit executable x86_64
/usr/bin/java (for architecture arm64e):    Mach-O 64-bit executable arm64e

So why is it running in Intel mode, and how can I run it natively?

2
  • How does this Java application get started?
    – nohillside
    Nov 2, 2021 at 17:00
  • @nohillside I run it from the command line /usr/bin/java blah_blah_blah.jar
    – Bill
    Nov 2, 2021 at 18:27

1 Answer 1

2

/usr/bin/java is not the Java runtime. It is a wrapper that will launch a Java runtime. You can determine which Java runtime/JDK you're actually using by examining java --version.

Java versions are typically installed in /Library/Java/JavaVirtualMachines. You can download an Apple Silicon native JRE/JDK and copy it to that location and remove existing ones to ensure this.

enter image description here

5
  • Thanks @ezekiel. So the only way to get an M1-native JDK is to download from a third party?
    – Bill
    Nov 2, 2021 at 18:27
  • 2
    @bill Java always is 3rd party :-)
    – nohillside
    Nov 2, 2021 at 19:54
  • @Bill Yes, For M1 or Intel, Java must be downloaded manually. There exist JDK and JRE packages that provide native functionality, with the same install process as Intel JDK/JRE packages. There is no change to M1 here.
    – Ezekiel
    Nov 2, 2021 at 20:14
  • Any recommendations for which JRE to use?
    – a06e
    Sep 3, 2022 at 12:13
  • 1
    @becko I usually use the Azul Zulu builds
    – Ezekiel
    Sep 4, 2022 at 13:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .