Java Reference
In-Depth Information
Figure 1.5
Use the java tool to interpret your Java bytecode.
Normally, when you run javac, you enter the name or names of Java source
code files that you want to compile. Because you just ran javac without enter-
ing any source code files, the help topics for javac were displayed, as shown in
Figure 1.4.
Running the JVM
After javac is running successfully, you should be able to type java and then
press Enter to run the JVM that comes with the SDK. Figure 1.5 shows the out-
put that you should see.
Normally, when you run java, you enter the name of the bytecode file that
contains the Java program you want to execute. If you saw an output similar
to Figure 1.5, you are ready to compile and run Java programs using the SDK.
So let's get started!
A Simple Java Program
It is common practice when learning a new programming language to start out
with a Hello, World program that simply displays the message, “Hello, World.”
So, we will now write a simple Java program that displays a greeting at the
command prompt.
Here are the steps we will follow in writing our first Java program:
1.
Write the source code.
2.
Compile the source code.
3.
Run the program.
Search WWH ::




Custom Search