wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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: 18546

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: 14074

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 7 API documentation
Scala Notes - My blog about Scala
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: http://aspose.com/file-tools
subject: java.lang.NoClassDefFoundError
Similar Threads
Ant error on trying to run an taskdef
Java EE5 Tutorial - 'ant create-tables' BUILD FAILED
Sun JavaeeTutorial jaxB examples
Can't ant build a component due to ?faulty? build.xml file.
@WebMethod not found