1

我已经在我的系统中安装了 jdk 7 和 jdk8。但是我的 java 程序正在 1.8 中编译版本并在 1.7 中执行。所以它响应 UnsupportedClassVersionError。我怎样才能克服这个问题...

4

4 回答 4

2

使用 jdk8 运行您的代码或使用 jdk1.7 编译它。

于 2014-07-27T07:34:47.203 回答
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.

阅读更多:

于 2014-07-27T07:34:34.350 回答
0

不要尝试这样做。

Java8 是比 Java7 更新的版本。因此,您使用 JDK1.8 编译的代码有可能无法使用 JDK1.7 执行,因为这可能不包含 JDK1.8 新的所需库或所需功能

例如,JDK1.5 及更高版本支持 for-each 循环、可变参数等。所以编译包含上述特性的源代码并尝试在JDK1.4或其以前的版本上运行程序总是会导致错误,因为这些JDK版本将无法识别此类代码片段。

但是,Oracle 的 JVM 支持向后兼容。因此,您始终可以在以前版本的 JDK 上编译代码并在最新版本上运行它。

于 2014-07-27T08:23:06.227 回答
0

在jdk8中运行并用jdk 7编译应该没问题。也许用jdk8编译并在jdk7中运行

于 2014-07-27T07:52:52.730 回答