Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes 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 "NoClassDefFoundError" Watch "NoClassDefFoundError" New topic


nirjari patel
Ranch Hand

Joined: Apr 23, 2009
Posts: 368
I have set path variable as "C:\glassfish3\jdk\bin\java" but its not working. SO I am giving complete path on command line. WHen I compile as "C:\>c:\glassfish3\jdk\bin\javac C:\Users\Admin\Desktop\jsp\" File is getting compiled and class file getting generated in jsp dir.

Now when I try to run this class file as follows, I am getting error.
Why am I getting such an error ? Why is path variable not getting set ? Whats this glassfish ? Can I not download jdk6 without glassfish ?

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

I think you're confusing the path and the classpath variables. I would advise you to read about them and not to use the classpath environment variable.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
nirjari patel
Ranch Hand

Joined: Apr 23, 2009
Posts: 368
Where does the question of PATH and CLASSATH arise, when I am giving complete path on command line for the class file ?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074

C:\>glassfish3\jdk\bin\java Users\Admin\Desktop\jsp\ReadAndWriteFromFile
Exception in thread "main" java.lang.NoClassDefFoundError: Users\Admin\Desktop\jsp\ReadAndWriteFromFile (wrong name: ReadAndWriteFromFile)

You're using the java command in the wrong way.

With the java command, you have to specify the fully-qualified class name of the class you are running, and not a file path. Use the classpath to specify which directories and JAR files Java must look in to find your class. Try this:

java -cp Users\Admin\Desktop\jsp ReadAndWriteFromFile

Glassfish is Oracle's reference implementation of the Java EE standard. Ofcourse you can download JDK 6 without Glassfish. But if you want to run JSPs, you do need a web container (you can't run JSPs with Java SE 6 alone).

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
nirjari patel
Ranch Hand

Joined: Apr 23, 2009
Posts: 368
I installed Java EE from with glassfish and then I was trying to open a page which required Java. I was getting error "Java is not installed". I clicked on the link that came alongwith message and it led me to I installed java from that link again and it started working. SO whats going on over here ? Why is Java EE not getting installed ? If its not getting installed, why am I not getting an error message and instead I am getting message "installation successful" ? How can I install Java EE , if its not working from ?

I agree. Here's the link:
subject: NoClassDefFoundError
Similar Threads
UnsupportedClassVersionError, help
Problem with setting classpath
Exception in thread "main" java.lang.NoClassDefFoundError: Voice1
ClassNotFoundException: org.apache.axis2.transport.SimpleAxis2Server
error because of classpath?