public class Hello { public static void main (String args[]) { System.out.println ("Hello, World!"); } } |
To run this program,
Hello.java
. (If you are on a PC, you may need to
name the file Hello.jav
.) Do not give the file
some other name.
javac Hello.java
Hello.class
(I'm not
sure what it is if you only have 3-character extensions.)
java Hello
Hello
, then it must be in a file named
Hello.java
. For PCs that can't have a four-letter
extension, the name must end in .jav
instead.
If your operating system has case-sensitive file names, the
first part of the file name (Hello
in this case)
must be capitalized the same way as in your program.
javac
requires the name of the
file (as you would expect), that is,
Hello.java
.
java
interpreter
that wants the name of the class only, with no
.class
extension--given the class name, it can figure
out the file name.