To make sure your Java environment is correctly configured, bring up a command-line prompt and type
javac nofile.java
If your computer responds with
error: Can't read: nofile.java
you're ready to begin. If, on the other hand, it responds
javac: Command not found
or something similar, then you need make sure you have the Java environment properly installed and your PATH configured.
Assuming that Java is properly installed on your system there are three steps to creating a Java program:
Under Unix, compiling and running the code looks like this:
$ javac HelloWorld.java $ java HelloWorld Hello World $
Under Windows, it's similar. You just do this in a DOS shell.
C:> javac HelloWorld.java C:> java HelloWorld Hello World C:>
Notice that you use the .java
extension when compiling
a file, but you do not use the .class
extension when
running a file.
For IDEs, consult your product documentation.