Copyright © 2004 Eclipse.org. All Rights Reserved

Adding a Class to Your Project

 

First, creat a package for your class. Select the project you created in the package explorer, right click, and select "New" > "Package" from the context menu. Name the package "myPackage" then click finish.

 

Select the package you just created, and from the context menu select “New" > "Class”. Name the class “HelloWorld” and select the option to let Eclipse create a new main method for you. Click "Finish".

 

Edit the text in the editor so that it looks something like this:

 

/*

 * Created on 20-Aug-2003

 *

 * To change this generated comment go to

 * Window>Preferences>Java>Code Generation>Code and Comments

 */

 

/**

 * To change this generated comment go to

 * Window>Preferences>Java>Code Generation>Code and Comments

 */

public class HelloWorld {

 

      public static void main(String[] args) {

            sayHello();

      }

     

      public static void sayHello() {

            System.out.println("Hello");

      }

}

 

Save the file.

 

Notice that unlike in a Java project, there was no eager parsing of the buffer as you typed (the outline view didn’t update). Your Eclipse workbench should be looking something like this: