无法找到Javac编译器 [英] Unable to locate the Javac Compiler

查看:145
本文介绍了无法找到Javac编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试 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


$ b b

我也尝试选择其中一个打开与 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仍然不起作用在指向javac二进制文件的/ usr / local / bin中创建一个符号链接: p>

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或sth。类似)

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屋!

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