File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes java.lang.NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java.lang.NoClassDefFoundError" Watch "java.lang.NoClassDefFoundError" New topic


abhishek kunal
Ranch Hand

Joined: Jul 27, 2009
Posts: 42
i am using ant command to build the project.using java sdk 1.6 14th update. while javac in is running well alone but when using ant it throws this message..

Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
Buildfile: build.xml





[echo] Compiling hello2
[echo] javaee.classpath.prefix is: c://sun//AppServer/lib
[echo] is.glassfish.v3 is: ${is.glassfish.v3}
[javac] Compiling 2 source files to C:\javaeetutorial5\examples\web\hello2\b

java.lang.NoClassDefFoundError: com/sun/tools/javac/Main (wrong name: sun/tools/

Total time: 1 second

i have tried every possible and genuine value for java_home like C:\Program Files\Java\jdk1.6.0_14\; and C:\Program Files\Java\jdk1.6.0_14\bin and C:\Program Files\Java\jdk1.6.0_14\lib ...but cdnt solve the problem....

please help!!
Henry Wong

Joined: Sep 28, 2004
Posts: 20370

java.lang.NoClassDefFoundError: com/sun/tools/javac/Main (wrong name: sun/tools/

It looks like you have classes that was compiled for a particular package and then simply moved to another package, without being recompiled.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15037

It looks like Ant is looking in the wrong directory to find the Java compiler (it says "jre6" in the error message, but the JRE does not include the Java compiler). Do you have a JDK installed, or only a JRE? You need to install the JDK.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
abhishek kunal
Ranch Hand

Joined: Jul 27, 2009
Posts: 42
yes i do have java sdk installed ...version 1.6 update 14...and it's also included(by me) in the path variable..i told earlier that, when i want to comile separately then i can compile well, but ant is not doing it with javac, may be its a problem of build.xml
I agree. Here's the link:
subject: java.lang.NoClassDefFoundError
It's not a secret anymore!