0

I am trying to install the ARM64 version of Java on my Raspberry Pi model 4.

I have already added arm_64bit=1 to the /boot/config.txt file and running uname -a returns Linux pi4 5.10.17-v8+ #1403 SMP PREEMPT Mon Feb 22 11:37:54 GMT 2021 aarch64 GNU/Linux. This shows that I am running the 64-bit kernel.

Installing JRE 11 with sudo apt install default-jre seems to be installing the 32-bit version of Java 11.

I first thought that apt was installing the 32-bit version and I had to change it to the ARM64 architecture so I followed this answer from another question. This only lead to more errors when I went to sudo apt update and didn't install the 64-bit version.

So the next thing I tried was dowloaded an aarch64 version of OpenJDK11. I did the following (slightly modified from here):

cd /home/pi/
wget https://cdn.azul.com/zulu-embedded/bin/zulu11.35.36-ca-jdk11.0.5-linux_aarch64.tar.gz
tar -xvzf zulu*tar.gz
mv zulu11.35.36-ca-jdk11.0.5-linux_aarch64 java-11-zulu-aarch64
mv java-11-zulu-aarch64 /usr/lib/jvm/java-11-zulu-aarch64
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-11-zulu-aarch64/java 1091

After I had set update-alternatives with the newly installed Java:

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-armhf/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-armhf/bin/java      1111      manual mode
* 2            /usr/lib/jvm/java-11-zulu-aarch64/bin/java       1091      manual mode
  3            /usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java   1081      manual mode

Running java -version outputs this:

-bash: /usr/bin/java: No such file or directory

What am I doing wrong and how can I get an installation of ARM64 Java JDK on my Raspberry Pi Model 4?

Could it be a possibility that I needed to have flashed the 64-bit Raspbian Lite OS from here, rather than flashing the 32-bit then setting arm_64bit=1?

0
0

Could it be a possibility that I needed to have flashed the x64 Raspbian Lite OS from here, rather than flashing the x32 then setting arm_64bit=1?

Looks like it. The flag just means run the kernel in 64-bit mode. All the applications and libraries will still be 32-bit.

4
  • I see, is there a way to change apt to install ARM64 based programs, or do I need to make lower-level modifications to achieve this? If I need to make lower-level modifications, then I think it'll be easier to just reinstall the OS making sure I use the 64-bit version
    – SidS
    Mar 18 at 18:40
  • you need to install the beta 64bit OS - downloads.raspberrypi.org/raspios_arm64/images Mar 18 at 22:57
  • The raspios_lite_arm64 from here should be fine too right? I was thinking of going with the lite version as I'm going to be running it headless
    – SidS
    Mar 19 at 13:32
  • Just installed the raspios_lite_arm64 image on the Pi, and after updating then running sudo apt install default-jdk, the 64-bit JDK installs successfully. I guess this answers my question - settings the arm_64bit flag isn't enough, you have to install the actual 64-bit OS
    – SidS
    Mar 19 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.