6 Replies Latest reply: Jun 18, 2010 2:27 AM by 843810 RSS

    EXCEPTION IN THREAD "MAIN"  java.lang.NoClassDef

    843810
      I am getting this error whenever i try to execute a java program.....

      I have setted the environment variables as follows:

      Classpath: C:\Program Files\Java\jdk1.5.0\bin;.;C:\Program Files\Java\jdk1.5.0\lib;.;C:\Program Files\Java\jdk1.5.0\lib\dt.jar;.;

      path: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Java\jdk1.5.0\bin;C:\Program Files\Java\jdk1.5.0\lib

      I am requesting you to provide a solution for the exception and to handle the error....Thanks in advance
        • 1. Re: EXCEPTION IN THREAD "MAIN"  java.lang.NoClassDef
          843810
          Paste the whole exception, the small part You presented tells nothing, excepting the fact that there is a lack of some class.
          • 2. Re: EXCEPTION IN THREAD "MAIN"  java.lang.NoClassDef
            843810
            exception in thread 'main' java.lang.NoClassDefFound Error: Sample/java

            I have created the simple java program named "Sample" and .java as an extension in notepad.
            This program is saved as a notepad in

            C:\Documents and Settings\***\My Documents\Java (Here, JAVA is the folder created so as to save the java programs)
            • 3. Re: EXCEPTION IN THREAD "MAIN"  java.lang.NoClassDef
              843810
              Did You name the file Sample.java? Check out the extension of the file cause sometimes it happens that notepad adds .txt at the end (Sample.java.txt) - if so, the compiler message is correct, there's no Sample.java. Also pay attention to the content of the Sample.java file. In the most basic form it should be:
              public class Sample {}
              The name of the class must be the same as the name of file (case sensitive!).
              • 4. Re: EXCEPTION IN THREAD "MAIN"  java.lang.NoClassDef
                843810
                The following code is the implementation of Sample.java program and i checked its extension too. That is Sample.java.txt


                class Sample
                {
                public static void main(String args[ ])
                {
                System.out.println("Java ");
                }
                }


                I am here providing the path where i installed Java: C:\Program Files\Java\jdk1.5.0

                After the installation i have got two folders in JAVA: jdk 1.5.0 and jre 1.5.0

                I have included only jdk files such as lib, bin and dt.jar in class path of environmental variables.

                Here i am again posting the settings:

                CLASSPATH: C:\Program Files\Java\jdk1.5.0\bin;.;C:\Program Files\Java\jdk1.5.0\lib;.;C:\Program Files\Java\jdk1.5.0\lib\dt.jar;

                PATH:%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Java\jdk1.5.0\bin;C:\Program Files\Java\jdk1.5.0\lib;.;C:\Program Files\Java\jdk1.5.0\lib;.;C:\Program Files\Java\jdk1.5.0\lib\dt.jar;

                Thank you for your reply
                • 5. Re: EXCEPTION IN THREAD "MAIN"  java.lang.NoClassDef
                  843810
                  The following code is the implementation of Sample.java program and i checked its extension too. That is Sample.java.txt


                  class Sample
                  {
                  public static void main(String args[ ])
                  {
                  System.out.println("Java ");
                  }
                  }


                  I am here providing the path where i installed Java: C:\Program Files\Java\jdk1.5.0

                  After the installation i have got two folders in JAVA: jdk 1.5.0 and jre 1.5.0

                  I have included only jdk files such as lib, bin and dt.jar in class path of environmental variables.

                  Here i am again posting the settings:

                  CLASSPATH: C:\Program Files\Java\jdk1.5.0\bin;.;C:\Program Files\Java\jdk1.5.0\lib;.;C:\Program Files\Java\jdk1.5.0\lib\dt.jar;

                  PATH:%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Java\jdk1.5.0\bin;C:\Program Files\Java\jdk1.5.0\lib;.;C:\Program Files\Java\jdk1.5.0\lib;.;C:\Program Files\Java\jdk1.5.0\lib\dt.jar;

                  Thank you for your reply
                  • 6. Re: EXCEPTION IN THREAD "MAIN"  java.lang.NoClassDef
                    843810
                    Your java configuration is ok, cause the compiler starts to work and results in error. As I said before the name of the file is incorrect, it should be Sample.java not Sample.java.txt. This is why the error occurs. Correct the name of the file, and then try again.