The “hello world” app is always the first thing most students do in any language. Java is no different, and I’ll show you how easy it is here.
This tutorial makes a few assumptions. We’ve assumed that you’ve installed the JDK and have it running. For this tutorial I’m using Ubuntu Linux at the command line, but the code is the same if you’re using Windows.
Step 1: Create File
Create a file called “HelloWorld.java”. In there type the following code:
1 2 3 4 5 6
This code is pretty self explanatory. We’re creating a class called “HelloWorld”. When that class executes the first thing that runs is the main() method. Within that method we have a System.out.println method that outputs text.
Step 2: compile
To compile this, we simply type:
This compiles into a file named HelloWorld.class
Step 3: Run
To run this file, we type in:
And it outputs text. It’s that easy!
Now find some ways to make text output interesting. There are thousands of cool things you can do at the console.