This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java.lang.NoClassDefFoundError" Watch "java.lang.NoClassDefFoundError" New topic
Author

java.lang.NoClassDefFoundError

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..

C:\javaeetutorial5\examples\web\hello2>ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
b\tools.jar
Buildfile: build.xml

-pre-init:

init:

default-ear:

-pre-compile:

bpp-actual-compilation:
[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
uild\web\WEB-INF\classes

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

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
author
Sheriff

Joined: Sep 28, 2004
Posts: 18499
    
  40

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


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

Henry


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
    
  16

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java.lang.NoClassDefFoundError
 
Similar Threads
Sun JavaeeTutorial jaxB examples
Can't ant build a component due to ?faulty? build.xml file.
Ant error on trying to run an taskdef
@WebMethod not found
Java EE5 Tutorial - 'ant create-tables' BUILD FAILED