JAVA_HOME does not point to the JDK

2019-03-17 13:29发布

I am trying to follow a tutorial about how to use ant to build and run your application. I've followed all the steps and have created the build file, but when I try to run ant it gives me this error.

BUILD FAILED /home/bilal/tmp/ant/build.xml:19: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK. It is currently set to "/usr/lib/jvm/java-6-openjdk/jre"

Any ideas how to resolve this issue ?

16条回答
做自己的国王
2楼-- · 2019-03-17 14:35

You installed java...

apt-get install default-jre

But not the JDK...

apt-get install default-jdk
查看更多
在下西门庆
3楼-- · 2019-03-17 14:36

It looks like you are currently pointing JAVA_HOME to /usr/lib/jvm/java-6-openjdk/jre which appears to be a JRE not a JDK. Try setting JAVA_HOME to /usr/lib/jvm/java-6-openjdk.

The JRE does not contain the Java compiler, only the JDK (Java Developer Kit) contains it.

查看更多
再贱就再见
4楼-- · 2019-03-17 14:36

for centos yum -y install java-1.7.0-openjdk-devel.x86_64

and update JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk.x86-64

查看更多
Evening l夕情丶
5楼-- · 2019-03-17 14:36

On Ubuntu 14.04, I found two parts to solving the problem:

  1. Remove /jre from the environment variable. For me: export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
  2. Install the JDK as well as the JRE: sudo apt-get install default-jdk
查看更多
登录 后发表回答