Skip to content

Starting a Project

Before you can edit any Java code, you must first create a project.

  • A project is a related collection of source files and other resources.

  • Eclipse will display selected files and folders that are in the project, based on the type of project it is.

The project name will become a subdirectory within your workspace directory.

  • Once your project has been created, you will see the project name listed in the Package Explorer view.

Drill

  • Close the Welcome tab (you can always reopen it from the Help menu.)
  • Choose File | New | Other....
  • In the search field type java p, then select Java Project from the search results.
  • Click Next
  • In the Project Name text box enter MyFirstProject.
  • Click Finish.
  • If you are prompted to Open Associated Perspective, click No
  • In the Package Explorer, open up your project and click on src.
  • Go to File | New | Other.
  • Type class in the search field and select Class from the results.
  • Click Next
  • For the Name: enter HelloEclipse.
  • Under Which methods stubs would you like to create, check the checkbox for public static void main(String[] args)
  • Click Finish.

You'll see Eclipse created the class and opened it in the Java editor. It also created a main method that's empty except for a "TODO" comment. Under the "TODO" comment, add:

System.out.println("Hello, Eclipse!");
* Type Cmd-S to save the editor contents. * Now go to the Run menu in the menubar and select Run.


Prev -- Up -- Next