Tuesday 30 November 2010

Writing your first Java application

In order to test if your Java JDK installation is working correctly the best thing to do is write a simple Hello App!

1. Open a terminal window
2. Create a new java file, e.g. vi Hello.java
3. Write a basic program to announce some text or comment:

public class Hello {
        public static void main(String[] args) {
                System.out.println("I am a java App!");
        }
}


4. Save the file
5. Run javac Hello.java (This should complete without any errors)
6. Run java Hello
7.  I am a java App! appears in the terminal

No comments:

Post a Comment