Navigating Eclipse
The best way to learn Eclipse is to use Eclipse.
Eclipse helps you walk-through the creation of a Hello World application. Click on Help then Cheat Sheets and select the option for Create a Hello World application. This will open a window in Eclipse which guides you through creating a basic Java application.
Perspectives
Eclipse has perspectives you can change to correspond with the type of project you are developing. You can change the perspective from the Window | Open perspective
menu option.
Creating Java Projects
Before creating a class for your project you need a project. In the main toolbar, click on the New Java Project button, or select File | New | Java project from the menu bar. You'll need to give each project a unique name. Please choose a name that will help you remember the project you're creating. At the end of the class you'll have a workspace full of projects and may wish to refer to code from previous projects.
For Java console applications you will select File | New | Java Project
. For web applications you'll select File | New | Dynamic Web Project
. The first time you create a particular type of project it may not be in the menu yet. Choose Other from the menu and browse to the project type.
Once you create a project Eclipse will create a folder in your workspace. That folder will include supporting files Eclipse thinks you will need for that type of project.
Creating Java Classes
After you create a Java Project you need to create classes to add to that project. Within your project right-click on the src
folder and select New | Class
. From there you can select options to add a package (see next topic) or check the box to include a method stub for main().
Packages
A Java package is a technique for organizing Java classes into namespaces similar to the file folders on your computer. While not required, developers recommend packages to organize your code. If you include a package name then you will need to also use that package name to refer to the class elsewhere in your application.
Saving your changes
Please save your changes often. I'll repeat this in case you weren't listening: Save changes often. There, I've just saved you an hour of rework at some point in the future. You can use the Save menu item in the File menu or click the Save icon on the toolbar.
Running your Application
To run your application, right-click on your class in the Package Explorer and select Run As | Java Application
. The Console view should appear at the bottom and display the output.