简体   繁体   English

无法在Linux Ubuntu 12.04上运行maven2

[英]Cannot run maven2 on Linux Ubuntu 12.04

I am trying to compile a program using maven in my Linux 12.04. 我正在尝试使用我的Linux 12.04中的maven编译程序。 In order to do, I use the mvn clean install command. 为此,我使用mvn clean install命令。 However I get a build error: 但是我得到了一个构建错误:

[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.

I check the path and indeed I am missing that critical file. 我检查了路径,确实我错过了那个关键文件。 This is what I have: 这就是我所拥有的:

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

So apparently, I am running openJDK, but I am missing files. 显然,我正在运行openJDK,但我丢失了文件。 How do I fix this? 我该如何解决?

Apparently I was missing some important packages. 显然我错过了一些重要的包裹。 I found the solution in this website: 我在这个网站找到了解决方案:

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

Please make sure that JAVA_HOME points to /usr/lib/jvm/java-6-openjdk-amd64/ 请确保JAVA_HOME指向/usr/lib/jvm/java-6-openjdk-amd64/

Run javac: 运行javac:

  javac

If it is not found, check the PATH: 如果找不到,请检查路径:

  echo $PATH

It should contain 它应该包含

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

Make sure you have choosen the proper jdk: 确保你选择了正确的jdk:

$ sudo update-alternatives --config java

I had to choose /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java to run mvn. 我不得不选择/ usr / lib / jvm / java-7-openjdk-amd64 / jre / bin / java来运行mvn。 Ominously, there resides a tools.jar in /usr/lib/jvm/java- 7 -openjdk-amd64/ , but not in /usr/lib/jvm/java- 6 -openjdk-amd64/ 不利的是,有位于/ usr / lib中/ JVM / Java的7 -openjdk-AMD64 /一个tools.jar中,但不是在/ usr / lib中/ JVM / Java的6 -openjdk-AMD64 /

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM