0

I was trying to set up a MineOS server on a Raspberry Pi when I ran into an issue where I couldn't update the java version to Java 16. The Raspberry Pi is running the ARM64 architecture and I got my JDK from https://adoptopenjdk.net/releases.html?variant=openjdk16&jvmVariant=hotspot. Here is the specific JDK I downloaded onto my Raspberry Pi: https://github.com/AdoptOpenJDK/openjdk16-binaries/releases/download/jdk-16.0.1%2B9/OpenJDK16U-jdk_aarch64_linux_hotspot_16.0.1_9.tar.gz. To install it and add it to my $PATH, I did:

tar -xf OpenJDK16U-jdk_aarch64_linux_hotspot_16.0.1_9.tar.gz -C /opt/
ln -s /opt/jdk-16.0.1+9/bin/java /usr/bin/java

When running java --version, I get /usr/bin/java: No file or directory. Does anyone know why this is? Before I figured out that Raspberry Pi supports ARM64, I did this on ARM32 and it worked fine, but I needed to be able to allocate more memory to a server, so I had to update to ARM64. If you need more information, I can provide it if necessary.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
User-92
  • 374
  • 3
  • 13
  • Does this work? `/opt/jdk-16.0.1+9/bin/java --version` If so, the symlink is wrong, and you could just modify the PATH to have `/opt/jdk-16.0.1+9/bin` – OneCricketeer Jul 16 '21 at 21:19
  • @OneCricketeer I forgot to mention this in the question, but whenever I go to the opt/jdk-16.0.1+9/bin/java directory and try to run java from there, it says almost the same thing `/opt/jdk-16.0.1+9/bin/java: No file or directory`, when the java file is 100% there. – User-92 Jul 16 '21 at 21:23
  • 1
    wouldn't it be enough to just run this instead? `pkg install openjdk16-16.0.1+9.1` – fatih Jul 16 '21 at 21:24
  • Did you make it executable? `chmod +x /opt/jdk-16.0.1+9/bin/java` – OneCricketeer Jul 16 '21 at 21:25
  • @OneCricketeer It's already executable – User-92 Jul 16 '21 at 21:34
  • @Fatih I want the jdk to be stored in /opt/ and easy to remove all of the files related to it. – User-92 Jul 16 '21 at 21:35
  • Can you update the question with `ls -laR /opt/jdk-16.0.1+9` – OneCricketeer Jul 16 '21 at 21:44
  • Related: https://stackoverflow.com/questions/67898586/install-java-16-on-raspberry-pi-4 & https://www.reddit.com/r/raspberry_pi/comments/nxdva3/install_java_16_on_raspberry_pi/ (which mentions just using Docker if you want to run a Minecraft Server) – OneCricketeer Jul 16 '21 at 21:47
  • @OneCricketeer I don't really want to change everything that I have set up to move it to Docker. Moving over to docker isn't likely to fix my problem either. – User-92 Jul 16 '21 at 21:59
  • 1
    `ldd /path/to/java` and look for unsatisfied dependencies – dave_thompson_085 Jul 16 '21 at 23:26
  • @dave_thompson_085 Something really strange happens when I run that command. On the arm32 java binary, it's fine, but running it on the aarch64 binary, I get "not a dynamic executable". Do you have a clue why that might be showing up? – User-92 Jul 16 '21 at 23:38
  • I'm going to vote to close the question so can rewrite a new one with more information on my intents, and more information to make it easier to understand and answer (If that's not against the guidelines) – User-92 Jul 17 '21 at 00:53

1 Answers1

1

I did this on ARM32 and it worked fine, but I needed to be able to allocate more memory to a server, so I had to update to ARM64

I assume you mean you are using different Pi now?

On a Pi3, I can do

wget https://github.com/AdoptOpenJDK/openjdk16-binaries/releases/download/jdk-16.0.1%2B9/OpenJDK16U-jdk_aarch64_linux_hotspot_16.0.1_9.tar.gz

sudo tar -xzvf -C /opt OpenJDK16U-jdk_aarch64_linux_hotspot_16.0.1_9.tar.gz

/opt/jdk-16.0.1+9/bin/java --version

Note: tar -xz is for TAR.GZ files, and you only wrote -x in the question...

And that gives me an error about the non-compatible binary, as expected since my Pi needs ARMv7.

From there, I would update the PATH without a symlink, like how is done in Install Java 16 on Raspberry Pi 4

So, that being said, if the file does indeed exist, then there is some other permissions issue you're having

I want the jdk to be stored in /opt/ and easy to remove all of the files related to it.

I see no real need for /opt. If you can use apt/pkg to install, then you can also use it to remove/purge files for it

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • 1
    You don't need `-z` with `-x`. Linux including Pi uses GNU tar, and GNU tar automatically adds any needed decompression on reading (`-x` or `-t`). – dave_thompson_085 Jul 16 '21 at 23:27
  • Well, I still want to know why the aarch64 version of the JDK doesn't work, even though the lscpu command clearly says that it's aarch64. I went ahead and downloaded the arm32 version of the JDK, and it works flawlessly, but whenever I try it with the aarch64 version, it says that it can't find the java binary. – User-92 Jul 16 '21 at 23:34