无法在Linux Ubuntu 12.04上运行maven2

时间:2014-01-27 21:20:46

标签: java linux maven ubuntu openjdk

我正在尝试在Linux 12.04中使用maven编译程序。为此,我使用mvn clean install命令。但是我收到了构建错误:

[ERROR] Unable to locate the Javac Compiler in:
  /usr/lib/jvm/java-6-openjdk-amd64/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.

我检查路径,确实我错过了那个关键文件。这就是我所拥有的:

user@modelX:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib$ ls
accessibility.properties  im                    net.properties
amd64                     images                psfontj2d.properties
calendars.properties      jar.binfmt            psfont.properties.ja
charsets.jar              javazic.jar           resources.jar
classlist                 jce.jar               rhino.jar
cmm                       jexec                 rt.jar
compilefontconfig.jar     jsse.jar              security
content-types.properties  jvm.hprof.txt         sound.properties
currency.data             logging.properties    swing.properties
ext                       management            tz.properties
flavormap.properties      management-agent.jar  zi
fontconfig.properties     meta-index

显然,我正在运行openJDK,但我丢失了文件。我该如何解决?

4 个答案:

答案 0 :(得分:2)

显然我错过了一些重要的套餐。我在这个网站找到了解决方案:

答案 1 :(得分:0)

In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

请确保JAVA_HOME指向/usr/lib/jvm/java-6-openjdk-amd64/

答案 2 :(得分:0)

运行javac:

  javac

如果找不到,请检查路径:

  echo $PATH

它应该包含

  /usr/lib/jvm/java-6-openjdk-amd64/bin

答案 3 :(得分:0)

确保选择了正确的jdk:

$ sudo update-alternatives --config java

我必须选择/ usr / lib / jvm / java-7-openjdk-amd64 / jre / bin / java来运行mvn。不幸的是,/ usr / lib / jvm / java- 7 -openjdk-amd64 /中存在tools.jar,而/ usr / lib / jvm / java中的不是 - 的 6 -openjdk-AMD64 /