JAVATM- The Beginnings
When learning a new programming language, the first task is normally to write a program which simply prints the words “Hello World” to your computer’s display. Once we have written, compiled, and executed the program, and verified that “Hello World” appears on the display, we have successfully run the HelloWorld program.
In your favorite text editor, or in your programming Integrated Development Environment (IDE), create a file named HelloWorld.java which contains the following:
Listing 1 - HelloWorld.java
1 public class HelloWorld
3 public static void main(String args)
5 System.out.println("Hello World");
To compile and run HelloWorld.java from the command line, type the following:
The Javac command runs the Java compiler which converts Java source file HelloWorld.java into bytecode file HelloWorld.class. Java source files are text files containing the syntax, or programming rules, of the Java programming language. All Java source files end with the extension .java .
The Java command runs the HelloWorld.class executable in the Java Virtual Machine (JVM). The following output is now visible on your computer display:
Congratulations, you’ve just run your first Java program!
Copyright ©2017 by Ralph Lecessi Incorporated. All rights reserved.