简体   繁体   中英

“Unable to find a javac compiler” error with Ant on Ubuntu

I am building aprofplot on Ubuntu using Apache Ant. When I enter the command ant in the folder containing build.xml, I get this error:

BUILD FAILED
/home/ashwin/aprof/aprofplot/nbproject/build-impl.xml:923: The following error occurred while executing this line:
/home/ashwin/aprof/aprofplot/nbproject/build-impl.xml:263: 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-7-openjdk-amd64/jre"

Total time: 2 seconds
ashwin@ashwin-VirtualBox:~/aprof/aprofplot$ javac --version
The program 'javac' can be found in the following packages:
 * default-jdk
 * ecj
 * gcj-4.8-jdk
 * openjdk-7-jdk
 * gcj-4.6-jdk
 * openjdk-6-jdk

I have openjdk installed too. What am I doing wrong? Do I have to install further packages?

It seems, you have wrong JAVA_HOME variable. It points to JRE, from your output:

It is currently set to "/usr/lib/jvm/java-7-openjdk-amd64/jre"

Not JDK. That is why, Ant can't locate the javac and fails. You have to modify it. Try to delete jre at the end, seems, javac should be under /usr/lib/jvm/java-7-openjdk-amd64/bin . So you have to set it to /usr/lib/jvm/java-7-openjdk-amd64

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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