Home
menubar
rss_feed

Previous Lesson Java Video Tutorials Main Next Lesson


Lesson 1: Hello World

If you cannot see the video below, please install the Adobe Flash Player.


Hello World




In this video lesson, you will learn how to program a small application called Hello World. Here are the steps involved:

  1. Open NetBeans IDE (Integrated Development Environment, maintained by Sun MicroSystems)
  2. Go to File —> New Project
  3. Choose the standard Java application and click Next
  4. Name your project 'HelloWorld' (no quotes)
  5. Project location: C:\javadev
  6. Check the 'Set as Main Project' and 'Create Main Class' checkboxes
  7. Name the Main Class 'HelloWorld' (no quotes)

You will now have a basic console project with one class that contains the main method. A main method is necessary to run any console application. This is what the main method looks like:

public static void main(String args[]) {


}

You will also see grayed-out lines that look something like this:

// TODO application code here


/**
 *
 * @author:
 *
*/

These are comments. They are for programmers' use to write notes about the code and other information. They do not affect the code execution, so you can just leave them as they are.

Now, you will need to put some code inside the main method so that you can make the application do something. Inside the curly brackets {} of the main method, type this:

System.out.println("Hello World!");

Your main method should now look like this:

public static void main(String args[]) {

    System.out.println("Hello World!");

}

Now, we need to build and run the application to see the output. Here are the steps:

  1. Go to Build —> Build Main Project
  2. At the bottom left of the IDE, on the Status bar, you should see 'Finished building HelloWorld'—this means it was successful
  3. Go to Run —> Run Main Project
  4. An output box should appear in the bottom half of the IDE. In it, you should see the output 'Hello World!'

Success! You have now programmed your first application in Java.





Previous Lesson Java Video Tutorials Main Next Lesson


Home | Reference | Play Games! | Blog | Forum | Site Map | Contact Us


shadow bottom image