Lab Exercises - Stats for Java

Exercise 1: Chosing and Seting up a Development Environment for Compiling Java Programs

To write code for your own analyses you need a Development Enviroment. To help you navigate through the myriad of decisions consult the Java Programming Resources. To get a first understanding of what the Java programming language is about, please review this Java Tutorial. Specifically review Lesson: Object-Oriented Programming Concepts of the Sun Java Tutorial. You may also download The Java Tutorial.

Develop java programs using the Eclipse IDE from Eclipse. Download the current 64-bit version of Eclipse IDE for Java EE Developers - Juno and install according to instructions.

Exercise 2: Create and Run a "Hello World" program.

Our hello world program is a java program that writes the words "Hello World!" to the standard system console.

  • Start Eclipse
  • Create a new Java Project by selecting the menu File->New->Project...
  • In the project wizzard window select category "Java" and select "Java Project" in the project list. Click "Next"
  • Enter a project name into the Project name field - "Hello World Project" and click "Finish"
  • Create a new Java class. First select your Hello World Project in the package explorer and click the "New Java Class" button in the toolbar (it shows a green circle with a white C)
  • Enter "HelloWorld" into the Name field and confirm that the box for "public static void main(String[] args)" method is checked. Click "Finish".
  • Replace the line
    // TODO Auto-generated method stub
    with the line
    System.out.println("Hello World!");
    and save the file which automatically compiles HelloWorld.java
  • Click the "Run" button in the toolbar (a green circle with a white triangle). You will be prompted to create a Launch configuration.
  • Select "Java Application" and click "New". Click "Run" to run the Hello World program. The console will open and display "Hello World!"

last modified: 1/14/13