如何为以前的Java版本构建jar? [英] How can I build a jar for a previous Java version?

查看:235
本文介绍了如何为以前的Java版本构建jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译我的代码并在其他服务器上运行它。问题是我的JRE版本是Java版本 1.6.0_13,而服务器上的Java版本是Java版本 1.4.2。

I am trying to compile my code and run it on a different server. The problem is my JRE version is Java version "1.6.0_13" and that on the server is Java version "1.4.2".

这给了我无法识别的类文件版本异常,当我尝试在服务器上运行jar时。由于必须设置各种依赖项,因此无法在服务器上编译代码。

This gives me "unrecognized class file version" exception when I try to run the jar on the server. I cannot compile my code on the server because of various dependencies I will have to set up.

所以我需要知道是否有一种方法可以使用Eclipse(这比命令行更容易,因为它可以处理依赖项)并使用1.4编译我的东西.2代替1.6.0_13。我是否必须从计算机上卸载JRE,然后重新安装以前的版本,然后进行编译,还是有一种简洁,简洁的方法?

So I need to know if there is a way to "use Eclipse" [this is easier than command line since it takes care of dependencies] and compile my stuff using 1.4.2 instead 1.6.0_13. Do I have to uninstall my JRE from my machine, then reinstall previous version and then compile or is there an elegant and cleaner way?

推荐答案

您应该在计算机的1.6侧安装1.4.2,并配置该eclipse项目以使用1.4.2 JDK 。可以将其他项目配置为使用1.6。

You should install 1.4.2 along side 1.6 on your machine, and configure that eclipse project to use the 1.4.2 JDK. Other projects may be configured to use the 1.6.

从技术上讲,您可以编译为与JDK 1.6兼容1.4.2,但是很可能会遇到库问题,因此它通常不值得做。

Technically you can compile to 1.4.2 compatibility with JDK 1.6, but odds are you will run into library problems, so it is not generally worth doing.

这篇关于如何为以前的Java版本构建jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆