I have a strange java issue. I'm working on a MacBook Air and doing some Java development work. I need my code to do the following:
// pseudo code
if (intel) {
// Load docker
} else if (arm) {
// Load ARM docker
}
It works for Intel and Linux-based ARM architecture. But for my M1 MacBook Air, it reports that the OS is Mac OS X but the architecture is reported as x86. Because of that last issue, I can't distinguish between the ARM and Intel machines.
Here's the JDK version I'm running. I feel like I'm missing something here, but is there some way I can write this code so that I can determine whether the code is running on an M1 or an Intel?
~ java --version
openjdk 11.0.12 2021-07-20 LTS
OpenJDK Runtime Environment Zulu11.50+19-CA (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.50+19-CA (build 11.0.12+7-LTS, mixed mode)
(base) ➜ ~ java -XshowSettings 2>&1 | grep " os."
os.arch = x86_64
os.name = Mac OS X
os.version = 11.5
Its probably because you're actually running a x86_64 Java VM through Rosetta on your M1 Macbook. At least AdoptOpenJDK doesn't even offer a native m1 version of Java 11. For Java 17, there is a native aarch64 version available: https://adoptium.net/releases.html?variant=openjdk17&jvmVariant=hotspot
In the Activity Monitor app bundled with your map, you can verify if an app (“process”) is running natively versus running under Rosetta 2. Find your process, likely named java, and look at the Kind column. Native apps say Apple while apps under Rosetta 2 say Intel.