Getting Things Done with Eclipse
Part of the Eclipse For Dummies Cheat Sheet
Once you’ve installed Eclipse, take advantage of all the features to enhance the IDE (integrated development environment) and create effective Java applications. Check out all the stuff you can do:
Create a project: Choose File→New→Project. In the New Project dialog, select Java Project and click Next. In the New Java Project Wizard, fill in the Project Name field and click Finish.
Create a package: Right-click a project in the Package Explorer’s tree. In the resulting context menu, choose New→Package. In the New Java Package dialog, fill in the Name field (with a name like com.allmycode.mypackage) and click Finish.
Create a Java class: Right-click a package in the Package Explorer’s tree. In the resulting context menu, choose New→Class. In the New Java Class Wizard, fill in the Name field. Then click Finish.
Create a main method: Place the cursor in the editor at the point where the main method belongs. Type main and press Ctrl+Space. In the resulting pop-up list, select main - main method.
Quickly correct a compiler error: Right-click the red error marker in the editor’s marker bar (to the left of the code). In the resulting context menu, choose Quick Fix. A list of possible fixes appears. Select an item in the list to find out how that item’s fix modified your code. When you find an item that you like, double-click the item or simply press Enter.
Format your code: Select one or more Java classes. Then, on the main menu, choose Source→Format. Eclipse doesn’t automatically save the code after formatting, so finish up by choosing File→Save.
Run a class that contains a main method: Select a class. (Select it in the Package Explorer, the Navigator view, the Outline view, or in an editor.) Then, on the main menu bar, choose Run→Run→Java Application.
Run a class with main method arguments: Select a class. (Select it in the Package Explorer, the Navigator view, the Outline view, or in an editor.) Then, on the main menu bar, choose Run→Run. A Run dialog appears. If the class that you selected doesn’t appear as a branch in the Run dialog’s tree, then double-click the tree’s Java Application branch. In the body of the Run dialog, select the Arguments tab. In the Arguments tab’s Program Arguments field, type the string values that you want to give to the main method’s arguments array. (Use blank spaces to separate the string values from one another. Don’t surround the string values with quotation marks.) Finally, click Apply and then click Run.
Allow one project to refer to other projects’ names: Right-click a project’s branch in the Package Explorer. On the resulting context menu, choose Properties. A Properties dialog appears. In the dialog’s left pane, select Java Build Path. Then, on the right side of the Run dialog, select the Projects tab. In the Projects tab’s list, put check marks next to projects that contain targeted names.
Close Eclipse and then reopen Eclipse using another workspace: On the main menu bar, choose File->Switch Workspace. Then in the Workspace Launcher dialog, type the name of the folder that contains the new workspace. Finally, click OK.