我在我的系统中安装了jdk 7和jdk8。但我的java程序正在1.8中编译版本并在1.7中执行。所以它响应UnsupportedClassVersionError。我怎样才能克服这个问题...
答案 0 :(得分:2)
使用jdk8运行代码或使用jdk1.7编译。
答案 1 :(得分:1)
如何解决此后续错误。
1) Find out due to which jar or class file this UnSupportedClassVersionError is coming?
2) Try to compile source code of that jar with the JDK version you are using to run your program, if source is available.
3) If you don't have source try to find the compatible version of that library.
4) Increase the JRE version you are using to run your program.
答案 2 :(得分:0)
在jdk8中运行并使用jdk 7编译应该可以。可以用jdk8编译并在jdk7中运行
答案 3 :(得分:0)
不要试图这样做。
Java8是比Java7更新的版本。因此,有可能您使用JDK1.8编译的代码,相同的代码可能无法使用JDK1.7执行,因为这可能不包含所需的库或JDK1.8中新增的所需功能
例如,JDK1.5及以后版本支持for-each循环,varargs等。因此,编译包含上述功能的源代码并尝试在JDK1.4或其先前版本上运行程序总是会导致错误,因为那些JDK版本将无法识别此类代码片段。
但是,Oracle的JVM支持向后兼容性。因此,您始终可以在以前版本的JDK上编译代码,并在最新版本上运行它。