Eclipse:导出要在较旧的JRE上执行的Runnable JAR文件 [英] Eclipse: export a Runnable JAR file to be executed on an older JRE
问题描述
到目前为止,从Eclipse导出Runnable JAR文件是从另一台计算机上的命令行启动Eclipse项目的最快方法. 查看此答案.
Exporting a Runnable JAR file from Eclipse is by far the quickest way to launch an Eclipse project from command line on another machine. See this answer.
一个问题是,如果要运行的计算机上安装的JRE早于Eclipse使用的JDK,则会出现此错误:
A problem is that if the JRE installed on the machine you want to run from is older than the JDK used by Eclipse, you get this error:
java.lang.UnsupportedClassVersionError: test_hello_world : Unsupported major.minor version 51.0
我知道在Eclipse上我可以以较低的遵从性级别构建项目(例如,用1.6
代替1.7
),但这似乎不会影响导出的JAR文件.
I know that on Eclipse I can build the project with a lower compliance level (e.g., 1.6
instead of 1.7
), but this does not seem to affect an exported JAR file.
关于如何导出要在较旧的JRE上执行的Runnable JAR文件的任何想法?
Any idea on how to export a Runnable JAR file to be executed on an older JRE?
推荐答案
此过程似乎对我有用(我已使用Java 1.2和Eclipse Juno进行了测试):
This procedure seems to work for me (I tested with Java 1.2 and Eclipse Juno):
- 创建一个新项目.
- 将执行环境设置为J2SE-1.2.
- 创建一个主类,该主类将一行输出到System.out.
- 运行项目.
- 导出可运行的jar.
- 在JRE 1.2中运行jar.
这篇关于Eclipse:导出要在较旧的JRE上执行的Runnable JAR文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!