使用两个版本的Java配置Maven [英] Configuring Maven with two versions of Java

查看:251
本文介绍了使用两个版本的Java配置Maven的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要两个Java版本. Java5和Java6在同一台机器上,因为我的一些项目支持Java6,而另一些项目则支持Java5.因此,我通过将Java6的路径放在JAVA_HOME中并将Java5的路径放在JAVA5_HOME中做到了.我在PATH变量中添加了两个JAVA_HOME.

I need two versions of Java ie. Java5 and Java6 on the same machine, as some of my projects support Java6 and some supports Java5. So I made it by putting the path of Java6 in JAVA_HOME and Java5 in JAVA5_HOME. I added both the JAVA_HOMEs in the PATH variable.

但是当我执行java -version时,默认情况下,我得到以下结果

But when I do java -version, then by default I am getting the following result

java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

是否可以将Java5与Java6一起获得?

Is it possible to get Java5 also along with Java6??

我还想知道,是否可以使用两个Java版本(Java1.6和Java1.5)来配置maven2,并在运行时使用所需的版本来构建项目?

Also I would like to know that, is it possible to configure maven2 with two versions of Java (Java1.6 & Java1.5) and use the required version for building the project in the run time?

推荐答案

因此,我通过将Java6的路径放在JAVA_HOME中并将Java5的路径放在JAVA5_HOME中来做到这一点.我在PATH变量中添加了两个JAVA_HOME.

So I made it by putting the path of Java6 in JAVA_HOME and Java5 in JAVA5_HOME. I added both the JAVA_HOMEs in the PATH variable.

并不是一个好主意(无论如何,其中一个将是第一个).您应该只添加JAVA_HOME并将其指向要使用的JDK(并按需切换).

Not really a good idea (and one of them will be first on the path anyway). You should add JAVA_HOME only and make it point to the JDK you want to use (and switch on demand).

我还想知道,是否可以使用两个Java版本(Java1.6和Java1.5)来配置maven2,并在运行时使用所需的版本来构建项目?

Also I would like to know that, is it possible to configure maven2 with two versions of Java (Java1.6 & Java1.5) and use the required version for building the project in the run time?

不. Maven使用JAVA_HOME,一次只能使用一个JDK.

No. Maven uses JAVA_HOME, you can only use one JDK at a time.

如果要使用2个不同的JDK构建相同的项目,则最好的选择是使用Hudson这样的CI引擎并设置构建矩阵.

If you want to build the same project with 2 different JDKs, your best option would be to use a CI engine like Hudson and to setup a build matrix.

这篇关于使用两个版本的Java配置Maven的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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