Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant and Eclipse

Tags:

java

eclipse

ant

Hi I am a beginner java programmer and recently I've started reading Thinking in Java 4th edition to consolidate my knoledge of java after I read Head first Java.Problem is that this book has it's own library and I can't seem to make it work in eclipse even after I did everything it said on the website guide.I instaled ant acordinly with this video guide http://www.youtube.com/watch?v=XJmndRfb1TU and i'm getting this error:

"Unable to locate tools.jar.Expected to find it in C:\Program files\Java\jre7\lib\tools.jar Buildfile:C:\TIJ4\code\build.xml

build:

BUILD FAILED C:\TIJ4\code\build.xml:59:J2SE5 required

Total time:0 seconds

I tried reinstaling JDK witch was suggested on a forum but it still dident work so I don't really know what to do.

Can anyone tell me how can I solve this problem? Also, more importantly, can't this be done with Eclipse alone without installing Ant(I've only used eclipse for code writing and compiling so I'm not very familiar with it)Thant you.

like image 446
Aly Avatar asked Oct 08 '11 13:10

Aly


1 Answers

You are using a JRE instead of a JDK. Install a JDK and point your PATH and JAVA_HOME variables to the JDK home, not to the JRE home.

I see that Ant is using the Java Home from the JRE, e.g. C:\Program files\Java\jre7\ But it should be C:\Program files\Java\jdk1.7.0\ or similar.

Check your system's environment variables (e.g. press Windows-Key and Pause together, then select Extended Settings > Environment Variables. Check that JAVA_HOME is set to the JDK installation path and that in the PATH variables, the folder of the JDK comes before the folder of the JRE (or remove/replace the JRE path altogether with the one from the JDK).

Ant needs to find the JDK first in the PATH.

like image 63
mhaller Avatar answered Oct 07 '22 13:10

mhaller