Results 1 to 7 of 7

Thread: HelloWorld.java

  1. #1
    Banned Sylvie's Avatar
    Join Date
    Aug 2004
    Location
    Hell
    Posts
    4,136
    Blog Entries
    4

    Default HelloWorld.java

    Okay so I have this book called: Java Programming for the Absolute Beginner. I typed in this on notepad:

    Code:
    /*
     * Hello World
     * The classic first program
     */
    
    public class HelloWorld {
    
      public static void main(String args[]) {
        System.out.println("Hello, world!");
      }
    
    }
    So, the thing says to compile it. It makes me install Java SDK and this crap that doesn't work on my computer.

    What I'm wondering is, is there a way to compile this stuff without going on the command prompt?
    </pre>

  2. #2
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,394
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    Quote Originally Posted by Genji View Post
    So, the thing says to compile it. It makes me install Java SDK and this crap that doesn't work on my computer.

    What I'm wondering is, is there a way to compile this stuff without going on the command prompt?
    </pre>
    The command line is by far the easiest way. What kind of problem are you getting when trying via the command prompt?

  3. #3
    Banned Sylvie's Avatar
    Join Date
    Aug 2004
    Location
    Hell
    Posts
    4,136
    Blog Entries
    4

    Default

    Well, the book says to enter "javac HelloWorld.java" in the directory where you saved it. I keep getting an error and the thing isn't working.

  4. #4
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,394
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    Quote Originally Posted by Genji View Post
    Well, the book says to enter "javac HelloWorld.java" in the directory where you saved it. I keep getting an error and the thing isn't working.
    What is the error? That's the thing I actually need to know.

  5. #5
    Banned Sylvie's Avatar
    Join Date
    Aug 2004
    Location
    Hell
    Posts
    4,136
    Blog Entries
    4

    Default

    Alright, so the default directory is:

    C:\Documents and Settings\Genji>

    I put in:

    C:\Documents and Settings\Genji> cd My Documents

    Because thats where the file is located.

    So I do that, and now its

    C:\Documents and Settings\Genji\My Documents>

    Now I put:

    C:\Documents and Settings\Genji\My Documents>javac HelloWorld.java
    'javac' is not recognized as an internal or external command, operable program or batch file.

    So thats the message I get.

  6. #6
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,394
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    The problem is that javac is not on your $PATH. run

    echo $PATH

    and it will show you what $PATH currently is. $PATH is where it searches for executables every time you type a command on the command line. Java directories have to be included in that list or else DOS can't find them. So you either have to add the Java directory to your $PATH, or you have to type the full pathname to javac every time you run it, i.e. c:\j2sdk_version\blah\blah\bin\javac or something similar.

    Try this: http://www.cs.colostate.edu/helpdocs/JavaPaths.html#XP

  7. #7
    Banned Sylvie's Avatar
    Join Date
    Aug 2004
    Location
    Hell
    Posts
    4,136
    Blog Entries
    4

    Default

    You're the man, you know that Unne?

    Thanks a ton, that was much more clearer than the book.

Posting Permissions

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