JDK运行时版本错误
大约 5 分钟
记一次打包java ant项目打包运行报错
根据教程导入项目编译打包 https://www.jianshu.com/p/122335716708
补充知识:ant编译步骤 https://blog.csdn.net/kone0611/article/details/83715470
运行报错
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: dev2dev/textclient/TextClient has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
猜测可能是java编译jdk和运行jdk不一致导致的,检查运行时jdk
PS C:\Users\EDY> java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
解决方案
考虑到运行时环境有其他软件依赖,下载了JDK17解压版直接运行,成功
参考
【JAVA】类文件具有错误的版本 61.0, 应为 52.0
https://blog.csdn.net/simonchi/article/details/126625381
【Java异常】完美解决this version of the Java Runtime only recognizes class file versions up to xx.0异常
https://blog.csdn.net/qq_44664231/article/details/131544077