Results 1 to 8 of 8
  1. #1
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default Problem with hello world.

    Java Code:
    class HelloWorldApp {
        public static void main(String[] args) {
            System.out.println("Hello World!"); // Display the string.
        }
    }
    When I try to type java helloworldapp.class i get this error Error: Could not find or load main class.

  2. #2
    Vampiricx3 is offline Member
    Join Date
    Feb 2012
    Posts
    31
    Rep Power
    0

    Default Re: Problem with hello world.

    When using command line to compile/run Java source code, it must be done as so.
    Java Code:
    javac (FILENAME).java
    java (FILENAME)
    You don't need to type .class after you call the java command.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

  4. #4
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default Re: Problem with hello world.

    I did so that all *. Class files to run with java but still i get this error.

  5. #5
    christopherx is offline Member
    Join Date
    Oct 2011
    Posts
    92
    Rep Power
    0

    Default Re: Problem with hello world.

    you aren't compiling or running the class file. You're compiling then running a java file.

  6. #6
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default Re: Problem with hello world.

    I know .

  7. #7
    gyijhbk is offline Member
    Join Date
    Feb 2012
    Posts
    61
    Rep Power
    0

    Default Re: Problem with hello world.

    Now I have another problem - the command java works but other javac command does not work.

  8. #8
    Vampiricx3 is offline Member
    Join Date
    Feb 2012
    Posts
    31
    Rep Power
    0

    Default Re: Problem with hello world.

    when using javac, you must do it as *.java. so as another example, I would compile my employee system like this.
    Java Code:
    javac Employee.java
    java Employee

Similar Threads

  1. Hello World Questions/Problem
    By NewtoWorld in forum New To Java
    Replies: 3
    Last Post: 10-14-2011, 07:36 PM
  2. Hello World, new!!!
    By omarovs in forum Introductions
    Replies: 1
    Last Post: 08-06-2011, 09:46 AM
  3. Hello world!
    By rgrant222 in forum Introductions
    Replies: 2
    Last Post: 07-30-2010, 05:52 PM
  4. hello world
    By wayne.seymour in forum Introductions
    Replies: 2
    Last Post: 02-11-2009, 01:19 PM
  5. Hello World!
    By joshua in forum Introductions
    Replies: 3
    Last Post: 02-03-2008, 01:41 PM

Posting Permissions

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