This is how you would display “Hello World” in your Java application.
We break the process of programming in Java into three steps:
- Create the program by typing it into a text editor and saving it to a file named, say, HelloWorld.java.
- Compile it by typing “javac HelloWorld.java” in the terminal window.
- Execute (or run) it by typing “java HelloWorld” in the terminal window.
So, the code in our file would look like
public class HelloWorld { public static void main(String[] args) { // Prints "Hello, World" in the terminal window. System.out.println("Hello World"); } }
To compile HelloWorld.java type the text below at the terminal
javac HelloWorld.java
Once you compile your program, you can execute it. This is the exciting part, where the computer follows your instructions. To run the HelloWorld program, type the following in the terminal window:
java HelloWorld
That’s it!