运行Java程序,javac运行.java文件没有报错,但java运行的时候报错
仔细看一下报错
Exception in thread “main” java.lang.UnsupportedClassVersionError: helloworld has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
查一下原因,发现为java与javac版本不一致而造成的。
java -version和javac - version一下,果真如此
两个版本不一致
解决:
1、查询Linux系统内有多少java版本
rpm -qa |grep java
2.然后一个个删除干净
rpm -e --nodeps java-1.8.0-