Installing Java on Dietpi64bit-beta Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
McFex
Posts: 8
Joined: Wed Aug 19, 2020 1:23 am

Installing Java on Dietpi64bit-beta

Post by McFex »

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 :(.

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:

Code: Select all

 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
User avatar
Joulinar
Posts: 2277
Joined: Sat Nov 16, 2019 12:49 am

Re: Installing Java on Dietpi64bit-beta

Post by Joulinar »

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 ... ds=openjdk

https://stackoverflow.com/questions/570 ... -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
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
McFex
Posts: 8
Joined: Wed Aug 19, 2020 1:23 am

Re: Installing Java on Dietpi64bit-beta

Post by McFex »

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.
User avatar
Joulinar
Posts: 2277
Joined: Sat Nov 16, 2019 12:49 am

Re: Installing Java on Dietpi64bit-beta

Post by Joulinar »

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.h ... #linux-pkg
  1. add the key

    Code: Select all

    wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
  2. crate a new source list

    Code: Select all

    nano /etc/apt/sources.list.d/java.list
  3. add following and save the file

    Code: Select all

    deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb buster main
  4. run following

    Code: Select all

    apt update
    apt install adoptopenjdk-8-hotspot
    reboot
At least on my test system I was able to install JAVA8

Code: Select all

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

Code: Select all

deb http://security.debian.org/debian-security stretch/updates main
Result is looking quite similar

Code: Select all

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. ;)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
McFex
Posts: 8
Joined: Wed Aug 19, 2020 1:23 am

Re: Installing Java on Dietpi64bit-beta

Post by McFex »

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

Code: Select all

$ 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.
User avatar
Joulinar
Posts: 2277
Joined: Sat Nov 16, 2019 12:49 am

Re: Installing Java on Dietpi64bit-beta

Post by Joulinar »

just use my small how-to. Much faster than dealing for zip files that would need to be uploaded and unpacked. ;)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
McFex
Posts: 8
Joined: Wed Aug 19, 2020 1:23 am

Re: Installing Java on Dietpi64bit-beta

Post by McFex »

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

*EDIT: Here is the link to the tutorial
viewtopic.php?f=15&t=8019
Post Reply