minecraft-server Java prolem

Installed an instance of games/minecraft-server.
Was getting the following error when trying to start it:

Code:
Error: A JNI error has occurred, please check your installation and try again Exception in thread “main” java.lang.UnsupportedClassVersionError: net/minecraft/server/Main has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Found a fix here which states:

pkg remove openjdk8
pkg install openjdk16


When I tried to remove openjdk8, pkg was also trying to remove minecraft-server, so I did:


pkg delete -f openjdk8


Then did

pkg install openjdk16


Worked fine until I started the server and got the following:
Code:
root@Bender:/usr/local/bin # ./minecraft-server
[13:35:55] [main/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[13:35:56] [main/WARN]: Ambiguity between arguments [teleport, location] and [teleport, destination] with inputs: [0.1 -0.5 .9, 0 0 0]
[13:35:56] [main/WARN]: Ambiguity between arguments [teleport, location] and [teleport, targets] with inputs: [0.1 -0.5 .9, 0 0 0]
[13:35:56] [main/WARN]: Ambiguity between arguments [teleport, destination] and [teleport, targets] with inputs: [Player, 0123, @e, dd12be42-52a9-4a91-a8a1-11c01849e498]
[13:35:56] [main/WARN]: Ambiguity between arguments [teleport, targets] and [teleport, destination] with inputs: [Player, 0123, dd12be42-52a9-4a91-a8a1-11c01849e498]
[13:35:56] [main/WARN]: Ambiguity between arguments [teleport, targets, location] and [teleport, targets, destination] with inputs: [0.1 -0.5 .9, 0 0 0]
[13:35:56] [main/INFO]: Reloading ResourceManager: Default
[13:35:58] [Worker-Main-13/INFO]: Loaded 7 recipes
[13:35:59] [Worker-Main-13/INFO]: Loaded 1137 advancements
[13:36:02] [Server thread/INFO]: Starting minecraft server version 1.17.1
[13:36:02] [Server thread/INFO]: Loading properties
[13:36:02] [Server thread/INFO]: Default game type: SURVIVAL
[13:36:02] [Server thread/INFO]: Generating keypair
[13:36:02] [Server thread/INFO]: Starting Minecraft server on *:25565
[13:36:02] [Server thread/INFO]: Using default channel type
[13:36:03] [Server thread/INFO]: Preparing level "world"
[13:36:10] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
[13:36:11] [Worker-Main-8/INFO]: Preparing spawn area: 0%
[13:36:11] [Worker-Main-10/INFO]: Preparing spawn area: 0%
[13:36:11] [Worker-Main-14/INFO]: Preparing spawn area: 0%
[13:36:12] [Worker-Main-8/INFO]: Preparing spawn area: 0%
[13:36:12] [Worker-Main-14/INFO]: Preparing spawn area: 1%
[13:36:13] [Worker-Main-11/INFO]: Preparing spawn area: 1%
[13:36:13] [Worker-Main-8/INFO]: Preparing spawn area: 1%
[13:36:14] [Worker-Main-9/INFO]: Preparing spawn area: 2%
[13:36:14] [Worker-Main-8/INFO]: Preparing spawn area: 2%
[13:36:15] [Worker-Main-10/INFO]: Preparing spawn area: 2%
[13:36:15] [Worker-Main-11/INFO]: Preparing spawn area: 2%
[13:36:16] [Worker-Main-8/INFO]: Preparing spawn area: 2%
[13:36:16] [Worker-Bootstrap-7/ERROR]: Unable to build datafixers
java.util.concurrent.CompletionException: java.lang.IncompatibleClassChangeError: Class com.mojang.datafixers.functions.PointFreeRule$$Lambda$1002/0x0000000838f5b5c0 does not implement the requested interface com.mojang.datafixers.functions.PointFreeRule

I don't know enough about Java (or any code for that matter) to understand what the problem is.
 
Yeah, there's your dependency hell. I actually avoid Java if I can help it.

Quickly checking the dependencies in games/minecraft-server shows that the dependency is still java/openjdk8. So, un-installing java/openjdk8 will of course remove games/minecraft-server.

Key thing to understand here is that the ports only depend on other things in the ports tree. It's not a good idea to go outside of the ports/package tree if you don't know what you're doing.

The 'quick fix': The date on the 'quick fix' you link to is Saturday 12 June 2021. The date on freshports.org is Last Update: 2021-08-03 15:52:28. Also - on the 'quick fix' page you linked to - the guy updated his minecraft server out of FreeBSD's tree (Caves and Cliffs update mentioned by Rubenerd is unlikely to be part of the official FreeBSD package). No idea what else was done so that his pkg commands were a success.

If this were my installation, I would install java/openjdk8 alongside java/openjdk16, they can coexist with proper config. THEN I would try to configure the Minecraft server to look for the openjdk16, rather than the openjdk8. There should be a .conf file somewhere, if you're willing to study how the Minecraft server is set up on FreeBSD.

I can tell that upgrading Java will solve the problem (The very last line of the Java error is where the issue is), but I'm not sure how to solve it cleanly on FreeBSD. But I can say this: Your post describes the problem very well. Somebody who's on top of things like Java and Minecraft on FreeBSD would be able to figure it out, and help you out! :)
 
Quickly checking the dependencies in games/minecraft-server shows that the dependency is still java/openjdk8.
It will use whatever Java is set as default. And the default Java is set to openjdk8. If you build from ports (or use Poudriere/Synth) you can set the default to OpenJDK11:
Code:
DEFAULT_VERSIONS+= java=11

OpenJDK11 is probably the version I would use, 16 is fairly new, so new Minecraft may not work with it yet.
 
From game version 1.17 you need openjdk16 so i think is not so wrong.
You're probably right. I looked up what version of Java has the class file version 60.0 and that's 16. https://javaalmanac.io/bytecode/versions/

So yes, OpenJDK16 is most likely what it's looking for. The games/minecraft-server port is configured to accept whatever is set as default. It should set JAVA_VERSION to 16+ to enforce a specific minimal version.

 
You're probably right. I looked up what version of Java has the class file version 60.0 and that's 16. https://javaalmanac.io/bytecode/versions/

So yes, OpenJDK16 is most likely what it's looking for. The games/minecraft-server port is configured to accept whatever is set as default. It should set JAVA_VERSION to 16+ to enforce a specific minimal version.

Ok... that was the original issue though
Code:
Error: A JNI error has occurred,
please check your installation and try again
Exception in thread “main” java.lang.UnsupportedClassVersionError:
net/minecraft/server/Main has been compiled by a more recent
version of the Java Runtime (class file version 60.0),
this version of the Java Runtime only recognizes class file versions up to 52.0

...and it seems my
pkg delete -f openjdk8
didn't actually delete what it said it did?


root@Bender:~ # pkg info | grep openjdk
bootstrap-openjdk8-r450802_2 Java Development Kit 8
openjdk16-16.0.1+9.1 Java Development Kit 16


Now I'm really confused.
 
Also...



root@Bender:/usr/local/openjdk16 # java -version
openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment (build 16.0.1+9-1)
OpenJDK 64-Bit Server VM (build 16.0.1+9-1, mixed mode, sharing)




root@Bender:/usr/local/openjdk16 # pkg delete openjdk8
No packages matched for pattern 'openjdk8'

Checking integrity... done (0 conflicting)
1 packages requested for removal: 0 locked, 1 missing
root@Bender:/usr/local/openjdk16 #

 
I'm successfully running several instances of games/minecraft-server v1.17.1 on FreeBSD 13.0-RELEASE p4.

As mentioned the key is to run minecraft-server on java/openjdk16.
As mentioned by SirDice this can be easily accomplished if you build your own package repository using ports-mgmt/poudriere (you can also do this locally - no need for a "real server¨!).
Enforcing the use of java16 can be easily accomplished by setting
Code:
DEFAULT_VERSIONS+= java=16
in your configuration file.
There might be more adequate solutions tho.

The port should certainly be updated. I'll consider submitting a patch.
 
Are you using data from an older server version in a newer server version? I mean Minecraft server version.

This is some abstruse stuff:

I think your profunctor optics are out of focus:
 
Are you using data from an older server version in a newer server version? I mean Minecraft server version.
Nope, these v1.17.1 instances were all starting off with a newly generated map (that they generated themselves upon first start).
 
Ok... that was the original issue though
Code:
Error: A JNI error has occurred,
please check your installation and try again
Exception in thread “main” java.lang.UnsupportedClassVersionError:
net/minecraft/server/Main has been compiled by a more recent
version of the Java Runtime (class file version 60.0),
this version of the Java Runtime only recognizes class file versions up to 52.0

...and it seems my
pkg delete -f openjdk8
didn't actually delete what it said it did?


root@Bender:~ # pkg info | grep openjdk
bootstrap-openjdk8-r450802_2 Java Development Kit 8
openjdk16-16.0.1+9.1 Java Development Kit 16


Now I'm really confused.

Also...



root@Bender:/usr/local/openjdk16 # java -version
openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment (build 16.0.1+9-1)
OpenJDK 64-Bit Server VM (build 16.0.1+9-1, mixed mode, sharing)




root@Bender:/usr/local/openjdk16 # pkg delete openjdk8
No packages matched for pattern 'openjdk8'

Checking integrity... done (0 conflicting)
1 packages requested for removal: 0 locked, 1 missing
root@Bender:/usr/local/openjdk16 #

Ah, now I see it. fullauto2012 , your quotes show that you have the bootstrap package for OpenJDK8 installed. I installed Java under FreeBSD in the past, so I can tell you that this bootstrap package is actually necessary for OpenJDK16 to actually run. What you have actually working at this point is OpenJDK16 (the version you actually need to have the latest Minecraft server running). So, don't delete that bootstrap package, you do need it - the chain of dependencies does link it to the Minecraft server.

FWIW, this reminded me of why exactly I'm avoiding Java on my installs - the recursion of dependencies for OpenJDK proved to be more than I have the patience for [to chase down and resolve]. 😩
 
Ah, now I see it. fullauto2012 , your quotes show that you have the bootstrap package for OpenJDK8 installed. I installed Java under FreeBSD in the past, so I can tell you that this bootstrap package is actually necessary for OpenJDK16 to actually run. What you have actually working at this point is OpenJDK16 (the version you actually need to have the latest Minecraft server running). So, don't delete that bootstrap package, you do need it - the chain of dependencies does link it to the Minecraft server.

FWIW, this reminded me of why exactly I'm avoiding Java on my installs - the recursion of dependencies for OpenJDK proved to be more than I have the patience for [to chase down and resolve]. 😩
I would rather walk over hot coals on my shiny new FreeBSD server... But, I have a 7 year old daughter that I would gladly step infront of a moving teain for, so Minecraft is a must... hahahahha
 
Back
Top