This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes problem building with ant - no classdef found for javac.main Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "problem building with ant - no classdef found for javac.main" Watch "problem building with ant - no classdef found for javac.main" New topic

problem building with ant - no classdef found for javac.main

Ed Mahoney

Joined: Sep 19, 2000
Posts: 14
I'm running j2sdk 1.4.1_01 (international version) and when I try to compile a java program with ant, I get the following message:
[javac] BUILD FAILED: file:C:/.../WEB-INF/src/build.xml:57: Unable to find a javac compiler; is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
Java_Home does seem to be pointing to the sdk. I found some messages on the net relating to the latest sdk having problems with javac. Should I roll back to a previous version of the sdk or could this be a problem with just the international version?
Thanks in advance,
SenthilKumar Natarajan

Joined: Mar 21, 2001
Posts: 15
Hi Ed,
You just try the previous version. I am using jdk1.3.1_03 with ANT its working properly.

Senthil Kumar Natarajan<br />SCEA
M.K.A. Monster
Ranch Hand

Joined: May 02, 2002
Posts: 130
There is a new update available now: JavaTM 2 SDK, Standard Edition Updates 1.4.1_02
Mark Monster
Ed Mahoney

Joined: Sep 19, 2000
Posts: 14
installing the new Jsdk did it. No more problems. Thanks.
Thomas Smets
Ranch Hand

Joined: Dec 11, 2001
Posts: 111
Thought the matter seems to be closed...

Did you add the ${JAVA_HOME}/bin to your PATH variable ?

Thomas Smets
Just another developper
Martijn Verburg

Joined: Jun 24, 2003
Posts: 3275

Hi all,

I have the same problem, JAVA_HOME is set to C:\j2sdk1.4.2_05 and PATH has C:\j2sdk1.4.2_05\bin in it, but I get the same error message, any ideas?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
mike rascher

Joined: Aug 06, 2004
Posts: 1
I had the same problem and reverting to an older jdk was not an option. Strangely, the problem was solved by changing the ant build.xml from this:

to this:

I haven't had time to play with the different flags to determine which one is the culprit.
Stephanie Nguyen

Joined: Dec 23, 2004
Posts: 1
I know this is somewhat of an old thread, but I was having the same problem and adding fork="yes" to the javac tag in ant solved it for me.
Jim Olsen

Joined: May 02, 2004
Posts: 3
I was also having this problem (on Windows). I think maybe I didn't set my JAVA_HOME variable until after Tomcat was installed so the installer set some Java stuff incorrectly.

In any case, copying %JAVA_HOME%\lib\tools.jar to %TOMCAT_HOME%\common\lib fixed the problem for me. I found this solution in http://localhost:8080/tomcat-docs/setup.html.
John Croucher

Joined: Sep 29, 2003
Posts: 9
Thanks Jim,
That solved the problem for me too. I also did not have the JAVA_HOME variable set prior to installing Tomcat 5.0. I am using j2sdk1.4.2_08 on Win XP SP2.

John M Croucher<br />Athens, OH
Al Krinker

Joined: May 25, 2005
Posts: 4
Thank you Mike!

I added fork="yes" and it worked!

p.s. If anyone needs experienced jdk install/uninstaller please let me know
I agree. Here's the link:
subject: problem building with ant - no classdef found for javac.main
jQuery in Action, 3rd edition