Installing Java on Dietpi64bit-beta

Hi guys,

I am quite new to all of this, so please don’t expect too much ground-knowledge here.

I used the search and browsed around, but what I needed was not found :frowning:.

A week ago I decided to build a Minecraft Forge server.
A friend suggested a raspberry pi.
So we got at it and flashed dietpi (the 64bit BETA version) on a 32GB SD-card and configured it (wifi,HDMI off,unabling root login) and installed what we needed (proFTP and MineOS).
Then we installed the minecraft server in MineOS, but the forge-version wouldn’t load or only stay up for seconds.
After some research I found out that the forge version we want to use (1.12.2) would need the corresponding java version, which is Java 8.
So I checked and found out that Dietpi has Javav11 installed,which lets you play normal 1.12.2 minecraft but not the forge-version.

Now I am desperately trying to change the java version on Dietpi.
And despite what every HowTo I found through google and on this site says, it is NOT easily downloaded via apt or apt-get.
I’m always shown 5 updatable packages (non of which is java) and then an error because the package can not be found.
I tried to get more information on which java (oracle or OpenJDK or something else?) to use, if JRE is enough or JDK is needed and where the f f*** to get the f****** tarballs to download for manual installation… :cry:
…but to no avail.
Meaning I found several tarballs to download (Oracle, OpenJDK, some Azul builds - I always used the 64bit version), but none of them seems to be the right one because after installing and telling the system where to find Java8 it says this:

bash: /usr/bin/java: cannot execute binary file: Exec format error

AAAAAAAAH!
Sorry, but if you are just beginning on linux and start to grasp that this is gonna be a neverending learning-curve it can get a bit emotional.

So here is my cry for help - please help me to install Java8 on my RPi4:

 DietPi v6.31.2 : 04:57 - Wed 08/19/20
 ─────────────────────────────────────────────────────
 - Device model : RPi 4 Model B (aarch64)
 - CPU temp : 36'C : 96'F (Cool runnings)
 - LAN IP : **************** (wlan0)
 - MOTD : Help testing the new RPi3/RPi4 64-bit image:
          https://github.com/MichaIng/DietPi/issues/3570

-Installed Software: proFTP, MineOS
-unabled root login

Tell me what else information you need from me, I will provide.
Thank you in advance,
McFex

Hi,

many thanks for your request. openjdk-8 is not available for your installation, as on Raspberry OS 64bit the standard Debian repository is used. The package available is openjdk-11 only.

https://packages.debian.org/search?lang=en&suite=buster&searchon=names&keywords=openjdk

https://stackoverflow.com/questions/57031649/how-to-install-openjdk-8-jdk-on-debian-10-buster

It would be different if you would use Raspberry OS 32bit because it’s using a different package source.

But this is quite independent from DietPi as DietPi is relying on the Raspberry OS base image below DietPi scripts

Thank you so much for your answer.
Although I’m confused now, whether the two links mean, there still is a possibility to install it.

If I understand you right, it is not possible to install Java 8, because Dietpi x64 is depending on the Debian 10 repositories which at this time don’t include a Java8x64 package.

Do you mean “not at all” possible or just not via apt-get?


Using a 32bit OS doesn’t make sense for me, since the goal is to setup a minecraft-forge server, which needs the 64bit economy to address the RAM it needs.

This has nothing to do with DietPi because DietPi themselves is not an own OS. DietPi is a set of Scripts on top of a Debian base image.

I case of Raspberry Pi devices, DietPi is using Raspberry OS. And the Raspberry Foundation has switched to standard Debian repository with introduction of the 64bit BETA

Anyway, there might be possibilities to get JAVA8 as described on the links. Means you would need to setup an additional package source (3rd party). Basically this link describe it well

https://adoptopenjdk.net/installation.html?variant=openjdk8&jvmVariant=hotspot#linux-pkg

  1. add the key
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
  1. crate a new source list
nano /etc/apt/sources.list.d/java.list
  1. add following and save the file
deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb buster main
  1. run following
apt update
apt install adoptopenjdk-8-hotspot
reboot

At least on my test system I was able to install JAVA8

root@DietPi3:~# java -version
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)
root@DietPi3:~#

But I need to say, I don’t have any experience with using AdoptOpenJDK and how reliable/ trustable it is. Therefore, everything you are going to do is on your own risk.

An alternative would be using Stretch repository. In this case, source list would be

deb http://security.debian.org/debian-security stretch/updates main

Result is looking quite similar

root@DietPi3:~# java -version
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-8u265-b01-0+deb9u1-b01)
OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)
root@DietPi3:~#

But not sure if it’s a good idea to add Stretch repo to a Buster system. At the end it would be your decision anyway. :wink:

Thank you so much for elaborating and explaining all this in detail. I see you even took the effort to test it.

However, I already followed the links you provided and literally just finished setting it up, just before I came back here to check and tell what I’ve achieved.

I tried to set up the additional packkage source, but I failed, since the commands from the post you linked to wouldn’t work in DietPi (I assume since you tested it, that it works. So I’m going to use your method when I do a clean install tomorrow).
But with the link to the tarball provided in that article (https://adoptopenjdk.net/installation.html) I decided to go for a manual installation.

I checked the architecture DietPi uses with

$ uname -a

and downloaded the corresponding file.

I put it on the server via FTP and moved it to the /usr/lib/jvm where the other openJDK stuff is stored, where I unzipped it.
Then I pointed DietPi to the right Java locations with the “update-alternatives”-command and configured it to use the new java installation.

Finally the “java -version”-command gave out the right java version.

I started the server with the forge-java-file chosen in MineOS and it worked!

Now I realize that there are some security risks here, not only in using this java version but also in the way I installed things.
Doing it via the added package source and letting the system install java where it belongs is definetly the better way to go.

I will make a post in the “Community Tutorials”-section about it, because I believe I won’t be the last one searching for this desperately.
Minecraft is a huge topic and the slim DietPi in combination with MineOS in a 64bit environment is a real optoin for a mroe than affordable (in both, pricing and power consumption) server you can play with your friends on.

I’ll link to it from here, once I’m done.

Thank you again, Joulinar, for your big help and the effort you took in helping.

just use my small how-to. Much faster than dealing for zip files that would need to be uploaded and unpacked. :wink:

Yes, thank you, it will definitely find it’s way in the tutorial!

*EDIT: Here is the link to the tutorial
https://dietpi.com/phpbb/viewtopic.php?f=15&t=8019