No Class Definition Found Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 3rds
    New Member
    • Jul 2008
    • 2

    No Class Definition Found Error

    I am completly new to Java and to programing in general. I have downloaded and installed JDK version 6, update 7 on my system runninig Windows XP SP3.
    I have the path set and the compiler running but when I try the java command I get this error message;

    Exception in thread "main" java.lang.NoCla ssDefFoundError : hello (wrong name: Hello)

    I copied the sorce code exactly from the instructions I am following and have been searching the web for an answer.
    Where did I go wrong?
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Hey there partner!

    Sorry for your troubles, I am sure it's annoying...

    What type of compiler are you using? I am also knew to this, if you're using Eclipse for instance, you can right-click on he red x where yourerror shows and you'll have a variety of options you can use.

    Hope you get this one nailed if it is so...

    In a bit!

    Comment

    • Laharl
      Recognized Expert Contributor
      • Sep 2007
      • 849

      #3
      Sounds like he's using the regular Sun command line tool. This is a classpath error. What you need to do is add '.', the current directory, to your Java classpath. How you do this I'm a little fuzzy, I'm afraid, as I use Linux, not Windows, for most of my dev work and use IDEs when in Windows for exactly this reason.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by 3rds
        Exception in thread "main" java.lang.NoCla ssDefFoundError : hello (wrong name: Hello)

        Where did I go wrong?
        The name of your class and/or file is wrong (see the error message). Java is
        case sensitive and you have mixed up an upper or lowercase letter.

        kind regards,

        Jos

        Comment

        • AIProgrammer
          New Member
          • Jul 2008
          • 28

          #5
          Hi,
          Your problem is that of CLASSPATH Settings. It is an 'Environment Variable' (If you find the term strange, then just a VARIABLE. If you are working on Windows XP, then follow the simple steps below:
          1. Right Click My Computer Icon in Desktop.
          2.Switch to the ADVANCED TAB.
          3.Add a Classpath variable to the system by clicking on new under USER VARIABLES.
          4. A box will pop-up.
          5. Enter CLASSPATH for VARIABLE NAME.
          6. Enter '.;' (DOT-Semicolon) for VARIABLE VALUE.

          The CLASSPATH simply specifies where your java.exe has to reside for successful execution of your program. You may ADD ANOTHER path by CONCATENATING it with the VARIBLE VALUE, separated by a semi-colon.

          Think that should help you out of that.

          AN ADVICE:

          Running Java Programs can be a headache if you ignore Cases in Class-names etc. After this preoblem is solved, look out if you made any mistakes of that kind.

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by AIProgrammer
            The CLASSPATH simply specifies where your java.exe has to reside for successful execution of your program.
            That is just nonsense. And the OP's problem isn't a classpath issue either: the
            JVM did find a file but the name didn't correspond with the class stored in that
            file. Probably an uppercase/lowercase problem. Setting the environment variable
            CLASSPATH is a clumsy way to set your classpath; read this for a nice
            explanation of what the classpath actually is. It is not for locating your java.exe;
            you'll need the PATH variable for that.

            kind regards,

            Jos

            Comment

            • 3rds
              New Member
              • Jul 2008
              • 2

              #7
              It was an uppercase/lowercase problem. Thanks for the help and advice. Now I can start moving forward again and maybe be a little more pleasent to be around.
              Thank You All

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by 3rds
                It was an uppercase/lowercase problem. Thanks for the help and advice. Now I can start moving forward again and maybe be a little more pleasent to be around.
                Thank You All
                Good to hear; lesson learned: always carefully read the error diagnostic message;
                all the information is in there (see your original post and error description). btw,
                you weren't unpleasant at all. Incorrect advice is more of a nuisance than questions
                like yours.

                kind regards,

                Jos

                Comment

                Working...