Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set $JAVA_HOME in eclipse but ANT Cannot Find Java Compiler

I add this line to /home/{user}/.bashrc file:

 export JAVA_HOME=/usr/lib/jvm/java-6-openjdk

but when I want to run an ant file in eclipse got this error:

BUILD FAILED
/home/bakish/Work/new/hadoop-0.20.2/build.xml:316: 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"

what should I do?

Thanks

like image 330
Shahryar Avatar asked Mar 14 '11 10:03

Shahryar


People also ask

How do I change my Java home directory in Eclipse?

Start -> Control Panel -> System -> Advanced -> Environment Variables. ... and you need to set JAVA_HOME (which is distinct from the PATH variable you mention) to reference the JDK home directory, not the bin sub-directory; e.g. "C:\program files\java\jdk". Save this answer.

Does Eclipse have a compiler for Java?

Eclipse has its own Java compiler, which is called [JDT Core][1] (org. eclipse. jdt.

What is Java home in Eclipse?

JAVA_HOME is an operating system (OS) environment variable which can optionally be set after either the Java Development Kit (JDK) or the Java Runtime Environment (JRE) is installed. The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed.


1 Answers

go to preferences / java / installed jre's -> add a new jre and select the location of your jre/jdk

like image 108
Alex_M Avatar answered Oct 01 '22 01:10

Alex_M