How to solve: Exception in thread "main" java.lang.UnsupportedClassVersionError

Problem: How to solve: Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/loader/WarLauncher : Unsupported major.minor version 52.0

Solution: This error usually means that you are trying to run ngrinder-controller with an unsupported version of Java. Unsupported major.minor version 52.0Means your java version is too low to run ngrinder-controller.

ngrinder-controller 3.5.2 requires at least Java 8 (version 52), so you need to make sure you have Java 8 or higher installed on your system.

You can check and update your Java version by following these steps:

1. Check the current Java version: java -version, this will display the currently installed Java version. If the version is lower than 8, continue to the next step.

2. Install Java 8 or later:

On CentOS 7, you can install OpenJDK 8 with: sudo yum install java-1.8.0-openjdk -y

After the installation is complete, you can run java -versionthe command again to verify the Java version.

4. Enter java -version again or display version 1.7.0_79, just restart the window

 5. Close the window, restart and enter java -version again to upgrade to the latest one.

6. Enter the command again: java -jar ngrinder-controller-3.5.2.war, it can be started normally.

Also: If you have successfully installed Java 8 (java-1.8.0-openjdk), but still shows the previous low version, it may be because there are multiple Java versions in the system, and the default Java version is still the lower version .

You can try the following to resolve this issue:

  1. Configure the default Java version: Configure the default Java version using the command: sudo alternatives --config java

    This will list all Java versions installed in the system and ask you to select the default Java version. Make your selection by number in the list and follow the prompts. Make sure Java 8 (java-1.8.0-openjdk) is selected as the default version.

  2. Check environment variable settings: Make sure your system's JAVA_HOMEenvironment variables are properly set to the path where Java 8 (java-1.8.0-openjdk) is installed. You can run the following command to check the environment variable settings: echo $JAVA_HOME

    If no output is displayed or the wrong path is displayed, manually set JAVA_HOMEthe environment variable using the following command:

    export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk

    Make sure to replace path /usr/lib/jvm/java-1.8.0-openjdkwith the path where you actually installed Java 8.

  3. Re-login or restart the system: In some cases, after changing the Java version, you need to re-login or restart the system for the changes to take effect. Please try to log back in or restart the system and check the Java version again.

 Hope to help you, thank you~

Guess you like

Origin blog.csdn.net/Along_168163/article/details/131764727