When running a Minecraft server on Ubuntu, you may encounter the “UnsupportedClassVersionError”. This error can be quite frustrating, but fortunately, it can be resolved by updating the Java Runtime Environment (JRE) on your system. In this article, we will guide you through the process of fixing this error.
To fix the "UnsupportedClassVersionError" when running a Minecraft server on Ubuntu with the latest JRE, you need to update your Java version to match the version the server was compiled with. Install Java 17 on your system, switch to using it as the default Java version, and you should be able to run your Minecraft server without encountering the error.
Understanding the Error
The “UnsupportedClassVersionError” typically occurs when the Java program you’re trying to run has been compiled with a more recent version of the Java Runtime than the one installed on your system. For instance, if your Minecraft server was compiled with Java 17 (which corresponds to class file version 61.0), but you’re running it on Java 11 (which supports class file versions up to 55.0), you’ll run into this error.
Checking Your Current Java Version
Before we start, it’s important to check the current version of Java installed on your system. You can do this by running the following command in your terminal:
This command will output the version of Java currently in use on your system.
Installing the Correct Java Version
If you find that your Java version is outdated, you’ll need to install the correct version. In this case, we’ll need Java 17. To install it, run the following command:
sudo apt install openjdk-17-jre-headless
In this command,
sudo is used to execute the command with root privileges.
apt is the package handling utility in Ubuntu,
install is the command to install a new package, and
openjdk-17-jre-headless is the package name for Java 17.
If Java 17 is not available in the Ubuntu repository, you can manually install it. Follow this tutorial to manually install Java 17 on Ubuntu.
Switching to the Correct Java Version
Once you have Java 17 installed, you’ll need to switch to using it. You can do this by running the following command:
sudo update-alternatives --config java
This command allows you to update the default Java version on your system. It will present you with a list of installed Java versions, and you can select the appropriate one (in this case, Java 17).
Running Your Minecraft Server
With the correct Java version installed and selected, you should now be able to run your Minecraft server without encountering the “UnsupportedClassVersionError”.
Resolving the “UnsupportedClassVersionError” when running a Minecraft server on Ubuntu involves checking your current Java version, installing the correct Java version, and switching to it. By following the steps outlined in this article, you should be able to resolve this error and get your Minecraft server up and running. If you encounter any issues, feel free to leave a comment and we’ll do our best to assist you.
To check the current version of Java installed on your Ubuntu system, open a terminal and run the command
java -version. This will display the version information of Java installed on your system.
If your Java version is outdated, you’ll need to install the correct version. In this case, you can install Java 17 by running the command
sudo apt install openjdk-17-jre-headless. If Java 17 is not available in the Ubuntu repository, you can manually install it by following a tutorial on how to install Java OpenJDK on Ubuntu.
Once you have the correct Java version installed, you can switch to using it by running the command
sudo update-alternatives --config java. This command allows you to update the default Java version on your system. You’ll be presented with a list of installed Java versions, and you can select the appropriate one (in this case, Java 17).
After installing and selecting the correct Java version, you should be able to run your Minecraft server without encountering the "UnsupportedClassVersionError" anymore. Make sure to start the server using the updated Java version by specifying the correct Java path or by adjusting your server startup script accordingly.
If you encounter any issues during the process of fixing the "UnsupportedClassVersionError" or have any other related questions, feel free to leave a comment below the article. We’ll do our best to assist you and provide guidance to resolve any problems you may encounter.