Unknown compiler error with Java.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #16
    Originally posted by nepomuk
    Well, in that case I'm glad, the bush isn't rose but red! ^^
    Ah, well then I guess I'll just have to drink another one again.

    Rose? What on earth I was thinking there ...

    Comment

    • Nepomuk
      Recognized Expert Specialist
      • Aug 2007
      • 3111

      #17
      Originally posted by r035198x
      Ah, well then I guess I'll just have to drink another one again.

      Rose? What on earth I was thinking there ...
      Quite, drink another to calm down from the shock. ^^ And then drink one for me, as I can't do so myself, would you? That would make me feel much better too!

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #18
        Originally posted by r035198x
        Rose? What on earth I was thinking there ...
        Please don't tell.

        Comment

        • Daveyyy
          New Member
          • Sep 2007
          • 5

          #19
          Hi again.

          I'm sorry that my descriptions on this forum are vague.. I am not used to help forum mannerisms what so ever. My apologies =)

          So I should mention once again that it compiles(I put compiler error, but it is actually running the program when the issue pops up)

          I am running JDK SE build 06 with Update 2.

          With Windows XP Pro SP2

          Everything that I can see.. and that my professor can see is correct. I am in the right directory and code is fine. She advised me to see support from the help desk here in my facility. But I don't think that will solve much.

          Another fellow in my class had the same problem and was directed by a mod in some forum to download a program which takes him around this error. I would rather just fix the error at it's source if possible.

          Code:
          import javax.swing.*;
          
          public class WelcomeInABox
          {
          	public static void main(String[] args)
          	{
          		JOptionPane.showMessageDialog(null, "Welomce to Java!", "Display Message", JOptionPane.INFORMATION_MESSAGE);
          	}
          	
          }
          That code also come up with the same error. Compiles just fine. but when I run it, comes up with the error

          "Exception in thread 'main' java.lang.NoCla ssDefFoundError : WelcomeInABox/java"

          So frustrated.

          Thaks again

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #20
            Read my reply #6 again and don't try to run any class as "package/classname".
            It doesn't work like that.

            kind regards,

            Jos

            Comment

            • Daveyyy
              New Member
              • Sep 2007
              • 5

              #21
              Well running it that way the error doesn't pop up instantly. It idles for a few seconds, then pops up.

              The way I was running(which is how I am instructed) is:

              java Welcome

              java -cp . Welcome gives me the same error..

              Some guy has mentioned that apparently the command line is attempting to run the .java file instead of the .class file? Does that sound right?

              Comment

              • Daveyyy
                New Member
                • Sep 2007
                • 5

                #22
                Ok, so problem solved.

                Apparently when I run the program i.e. java -cp . Welcome

                I need to actually use Welcome.class or it automatically trys to run the .java file. This is odd to me because noone else is doing this. But.. if I simply use Welcome.class it runs just fine.

                I appreciate all the help received.

                Dave

                Comment

                • JosAH
                  Recognized Expert MVP
                  • Mar 2007
                  • 11453

                  #23
                  Originally posted by Daveyyy
                  Ok, so problem solved.

                  Apparently when I run the program i.e. java -cp . Welcome

                  I need to actually use Welcome.class or it automatically trys to run the .java file. This is odd to me because noone else is doing this. But.. if I simply use Welcome.class it runs just fine.

                  I appreciate all the help received.

                  Dave
                  The java virtual machine will never attempt to run a .java source file; you also
                  shouldn't supply the .class suffix; the java virtual machines assumes such an
                  extension already (unless you specifiy a .jar file). The correct command line
                  (for now) is:

                  Code:
                  java -cp . Welcome
                  kind regards,

                  Jos

                  Comment

                  Working...