마인크래프트 서버 1.17 오류 해결: Java 버전 불일치 해결 방법

화면에 보여진 에러가 아래와 같은 경우, 적용 가능합니다.

root@java-contaianer:~/test-server# java -Xmx1024M -Xms1024M -jar server.jar nogui
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 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)

  1. JDK 다운로드

https://jdk.java.net/16/

wget https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_linux-x64_bin.tar.gz

2. jdk16 풀어준다

tar xvf openjdk-16.0.1_linux-x64_bin.tar.gz

3. jdk-16-0.1 폴더 확인하고, 아래 커맨드 실행.

~/jdk-16.0.1/bin/java -Xmx1024M -ms1024M -jar server.jar nogui

시작 파일 생성

# Open the script file 
vim startup.sh

# Add the code 
~/jdk-16.0.1/bin/java -Xmx1024M -ms1024M -jar server.jar nogui

# Grant the permission
chmod 755 startup.sh

# Execute
./startup.sh

설치된 서버는 상시 가동됩니다.

# Use screen command
screen

# execute the server 

./startup.sh