无法找到Javac编译器:

时间:2013-01-22 12:56:57

标签: java linux centos openjdk

我已经安装了OpenJDK,如下所述。但我仍然继续得到这个错误。我在bash_profile中设置了正确的PATH。

有人可以帮我解决这个问题吗?

 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-     plugin:2.3.2:compile (default-compile) on project poker-protocol: Compilation failure
 [ERROR] Unable to locate the Javac Compiler in:
 [ERROR] /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../lib/tools.jar
 [ERROR] Please ensure you are using JDK 1.4 or above and
 [ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
 [ERROR] In most cases you can change the location of your Java
 [ERROR] installation by setting the JAVA_HOME environment variable.
 [ERROR] -> [Help 1]
 [ERROR] 
 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
 [ERROR] 
 [ERROR] For more information about the errors and possible solutions, please read the following articles:
 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
 [ERROR] 
 [ERROR] After correcting the problems, you can resume the build with the command
 [ERROR]   mvn <goals> -rf :poker-protocol

在我的bash_profile中我有这个:

 JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre
 export M2_HOME=/usr/local/apache-maven-3.0.4
 export PATH=${M2_HOME}/bin:${PATH}:$JAVA_HOME/bin

有人能帮助我吗?

3 个答案:

答案 0 :(得分:4)

您已经安装了Java运行时,但是要开发Java应用程序需要JDK,因此必须安装OpenJDK开发包,在您的情况java-1.6.0-openjdk-devel-1.6.0.0.x86_64中。

答案 1 :(得分:0)

不太确定,但就我而言,我已经这样设置了:

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_11/
export PATH=$JAVA_HOME/bin:$PATH

我已在bash.bashrc

中完成此操作

在提供变量名称之前尝试添加export。我发现甚至认为我没有使用openjdk的另一件事是,tool.jar不在jre目录中,而是在jdk目录下。

希望这有帮助。

答案 2 :(得分:0)

你需要安装 java-1.6.0-openjdk-devel 安装java-1.6.0-openjdk只需安装JRE。