Once your Codespace is Set, it will Open.

3 min read


2 commits



Native Minecraft Servers that use GraalVM Native Image



The Minecraft server can be difficult to deploy because it requires a large amount of memory and CPU resources. This project allows to compile the Minecraft server into an executable that is self-contained and independent by using GraalVM Native Image. As such, it is expected to use less resources for memory and CPU as well as provide faster startup times, and be simpler and less expensive to deploy.



A native Minecraft server is smaller than Minecraft's server.jar and the JDK required to run it. The native executable can be compressed further to shrink its size to less than 40MB. This is smaller than the server.jar. Initial tests also revealed a comparable run-time performance and a smaller memory footprint. For the best results, build with GraalVM Enterprise Native Image which provides better performance and lower memory usage than the Community Edition, and try using the G1 GC and Profile-Guided Optimizations. Safeminecraftmods.Com The Oracle Cloud Free Tier not only provides four Ampere A1 cores and 24 GB of RAM always free, which is plenty for hosting the Minecraft server and also provides access to GraalVM Enterprise.



For more information, refer to this blog post.



Disclaimer: This project is intended to be used for demonstration purposes only. It's designed to assist the Minecraft community assess the use of GraalVM Native Image. Use at your own risk.



1. Download GraalVM Community or Enterprise (GraalVM 22.2.0 or later is required). Optional: Make sure that upx is installed on your $PATH to enable compression 2. Visit the repository and download it. Then run build.sh. 3. Launch the native Minecraft server with ./native-minecraft-server. You must agree to Minecraft's EULA the first time you launch the server.



How It Works



This project only contains the build.sh script along with reachability metadata and instructions to create the native Minecraft server. The build.sh script downloads Minecraft's server.jar first and extracts the jars it contains. Afterward, it invokes GraalVM Native Image with the right configuration to create an original version of the Minecraft server. In the end, if upx is in the $PATH, the script will compress native executable.



Limitations and known issues



The configuration currently supports Minecraft 1.18.2. The server GUI isn't fully supported as of yet. Mods are not currently supported. There isn't a built script for Windows yet, however the WSL should be able to work. - The native executable sometimes fails upon starting. It is typically possible to restart it several times. Error: com.mojang.datafixers.types.templates.List$ListType cannot be cast to java.lang.Comparable.

In case you have found a mistake in the text, please send a message to the author by selecting the mistake and pressing Ctrl-Enter.
Comments (0)

    No comments yet

You must be logged in to comment.

Sign In / Sign Up