为什么maven会忽略我的JAVA_HOME? [英] Why maven ignores my JAVA_HOME?

查看:118
本文介绍了为什么maven会忽略我的JAVA_HOME?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从CruiseControl执行 mvn 时,这就是我所得到的:

This is what I'm getting when mvn is executed from CruiseControl:


Unable to locate the Javac Compiler in:
  /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../lib/tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

同时,从命令行启动它会得到正确的结果。为什么 mvn 进入这个 tools.jar ?为什么忽略我的 JAVA_HOME ?我该如何解决?

At the same time, starting it from command line gives correct result. Why mvn is going into this tools.jar? Why it is ignoring my JAVA_HOME? And how can I fix it?

我不知道 JAVA_HOME / PATH 的值是什么时候 mvn 从CC启动。我真的很想得到这些信息,但我不知道如何。 CC本身是从用户 cc env 开始的,这个用户给了我(它是CentOS 5.4):

I don't know what are the values of JAVA_HOME/PATH when mvn is started from CC. I would really love to get this information but I don't know how. CC itself is started from user cc and env for this user gives me (it's CentOS 5.4):

JAVA_HOME=/usr/java/default
PATH=/usr/local/maven/bin:/usr/local/bin:/bin:/usr/bin:/home/cc/bin


推荐答案

假设你有一台linux机器。

Assuming that you have a linux machine.


  1. 看看 / usr / bin / java ,这是一个符号链接。看看这个符号链接的目标在哪里(在我的情况下,目标位于此位置 / etc / alternatives / java

  2. / etc / alternatives / java 也是符号链接。创建到正确JVM的新符号链接(例如Sun的JVM)

  3. 用新创建的符号链接替换 / etc / alternatives / java

  1. Take a look on /usr/bin/java, this is a symbolic link. Look where is a target of this symbolic link (in my case the target is at this location /etc/alternatives/java)
  2. /etc/alternatives/java is symbolic link too. Create new symbolic link to "proper" JVM (e.g. Sun's JVM)
  3. Replace /etc/alternatives/java with newly created symbolic link.

这适用于Ubuntu发行版。有一种自动方式如何做但我实际上忘记了:D

This works for Ubuntu distribution. There is an automatic way how to do that but I forgot it actually :D

这篇关于为什么maven会忽略我的JAVA_HOME?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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