无法找到 Javac 编译器 [英] Unable to locate the Javac Compiler
问题描述
我尝试 mvn install
并收到此消息:
I tried to mvn install
and got this message:
Compilation failure
Unable to locate the Javac Compiler in:
/usr/lib/jvm/java-7-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.
嗯,有一个开放的jdk,我也下载了另一个.我试图将 JAVA_HOME 指向两者,现在它已设置:
Well, there is an open jdk, I also downloaded another one. I tried to point JAVA_HOME to both, now it is set:
JAVA_HOME=/usr/lib/jvm/jdk1.7.0_03
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
我也尝试选择使用 sudo update-alternatives --config java
打开的其中一个,但在其中使用不同的 jdk 版本时出现相同的错误.
I also tried to choose one of those open with sudo update-alternatives --config java
but got the same error with different jdk versions in it.
我该如何解决?提前致谢.
How can I fix that? Thanks in advance.
推荐答案
似乎您的 PATH 没有正确选择...echo $PATH"的输出是否包含 javac 所在的目录?我建议如下:
it seems like your PATH is not picked up correctly... does the output of "echo $PATH" contain the directory where javac resides? I would suggest following:
打开终端并执行:
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_03
export PATH=$PATH:$JAVA_HOME/bin
javac -version
which javac
如果 javac -version 仍然不起作用,请在/usr/local/bin 中创建一个指向您的 javac 二进制文件的符号链接:
if javac -version still does not work create a symlink in /usr/local/bin pointing to your javac binary:
cd /usr/local/bin
ln -s /usr/lib/jvm/jdk1.7.0_03/bin/javac javac
这应该能让你开始...另一种方法是尝试通过您的包管理系统设置 java(例如apt-get install java"或类似的东西)
this should get you up an running... an alternative is to try setting up java via your package management system (e.g. "apt-get install java" or sth. similar)
这篇关于无法找到 Javac 编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!