Results 1 to 9 of 9
Like Tree1Likes
  • 1 Post By jim829

Thread: Compiling HelloWorld and Error with java and javac

  1. #1
    daveabes is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Default Compiling HelloWorld and Error with java and javac

    Hi guys. New to java here. Did the "Hello World!" output program today.
    The coding is fine through netbeans.
    After saving the file, I go to the folder holding the .java file and run javac.
    It completes and I have a .class file.
    When running java on the .class file however Im getting the java.lang.NoClassDefFoundError: Helloworld (Wrong name: none/HelloWorld.

    Im getting this with all the attempts I make no matter how I create them.

    Any help is much appreciated.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,616
    Rep Power
    5

    Default Re: Compiling HelloWorld and Error with java and javac

    Does the code contain a package definition? From what relative directory are you trying to run the program?

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,963
    Rep Power
    8

    Default Re: Compiling HelloWorld and Error with java and javac

    Please post the code you're trying to run, the directory structure of your files, and the exact input and output of the command line.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,616
    Rep Power
    5

    Default Re: Compiling HelloWorld and Error with java and javac

    At the half -- (Kevin: 1, Jim: 1) :)

    Regards,
    Jim
    KevinWorkman likes this.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,526
    Blog Entries
    7
    Rep Power
    20

    Default Re: Compiling HelloWorld and Error with java and javac

    Quote Originally Posted by jim829 View Post
    At the half -- (Kevin: 1, Jim: 1) :)
    But for a large value of 1, Jim is the winner because he replied first.

    kind regards,

    Jos (0.2)
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,616
    Rep Power
    5

    Default Re: Compiling HelloWorld and Error with java and javac

    Ah, but I was referring to this too.

    While() stops when encountering null


    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  7. #7
    daveabes is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Default Re: Compiling HelloWorld and Error with java and javac

    OK, so it has been determined that netbeans must build the executable java file since it adds all the neccessary class paths. Doing it via javac, compiles the prog but does not add the paths.

    Doing it through netbeans, then running it from the CLI, works.
    I suppose, when working on larger projects, netbeans being so difficult about things will be more understandable.

    Many thanks guys, your assistance was appreciated.

  8. #8
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: Compiling HelloWorld and Error with java and javac

    Quote Originally Posted by daveabes View Post
    I suppose, when working on larger projects, netbeans being so difficult about things will be more understandable.
    You want it to be as critical as possible, yes. Difficult is too negative, you use Netbeans for a reason and that is to effectively build something which works in a reduced time frame. I personally love the additional checks that an IDE does and the instant feedback that it gives.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #9
    daveabes is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Default Re: Compiling HelloWorld and Error with java and javac

    Eye to that gimbal2.

Similar Threads

  1. Error: Could not find or load main class HelloWorld
    By philodriscoll in forum New To Java
    Replies: 7
    Last Post: 10-10-2012, 03:44 PM
  2. Java compiling Error
    By BatchBat in forum New To Java
    Replies: 6
    Last Post: 07-15-2012, 07:32 PM
  3. Error with javac and java command
    By pateldpk in forum New To Java
    Replies: 3
    Last Post: 04-13-2012, 04:53 PM
  4. Java compiling error
    By fadijava in forum New To Java
    Replies: 21
    Last Post: 10-15-2009, 08:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •