Eclipse For Dummies

Eclipse is an open-source, integrated development environment and a great all-in-one tool for developing and running computer programs. It can help you with a multitude of projects, especially in Java.






>


>


Getting Things Done with Eclipse


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.







>



>


>


Searching for Text in Eclipse


As your Eclipse project gets larger and more complex, being able to find specific snippets of Java code easily becomes important. Luckily, Eclipse offers you multiple ways to search for text in your Java code:



  • Locate text in one file: Select a file in an editor. Then, on the main menu, choose Edit→Find/Replace. The Find/Replace dialog appears. In the dialog’s Find field, type the text that you want to locate. If you intend to replace text, type the replacement text in the Replace With field. Then click Find, Replace/Find, Replace, or Replace All.



  • Locate text in a collection of files without regard to the meaning of the text in a Java program: Select the files that you want to search. (Select them in the Package Explorer or the Navigator view.) Then, on the main menu, choose Search→File. The Search dialog appears. (The Search dialog displays its File Search tab.) Type the text that you want to locate in the Containing Text field. Choose Selected Resources in the lower half of the File Search tab. Then click Search.



  • Locate text in a collection of files, taking into account the meaning of the text in a Java program: Select the files that you want to search in the Package Explorer or the Navigator view. Then, on the main menu, choose Search→Java. The Search dialog appears. (The Search dialog displays its Java Search tab.) Type the text that you want to locate in the Search String field. Narrow your search with the Search For and Limit To radio buttons. Choose Selected Resources in the lower half of the File Search tab. Then click Search.







>



>


>


Dealing with Javadoc Comments in Eclipse


When you use Eclipse to write Java code, don't forget to edit the Javadoc comments (the things that start with /**). You can add useful information when you edit the Javadoc comments, and as you edit them, Eclipse's code assist offers suggestions. Remember these tips as you edit your Javadoc comments:



  • Add a Javadoc comment: Place the cursor in the editor at the point where the new Javadoc comment belongs. Then choose Source→Add Javadoc Comment from the main menu bar.



  • Create Javadoc pages from existing Javadoc comments: Select the projects or source files whose Javadoc pages you want to create. (Select them in the Package Explorer, the Navigator view, the Outline view, or in an editor.) Then, on the main menu bar, choose Project→Generate Javadoc.



  • See an existing Javadoc page: Select the element whose Javadoc page you want to see. (Select it in the Package Explorer, the Outline view, or in an editor.) Then, on the main menu bar, choose Navigate→Open External Javadoc.







>



>


>


Getting Help from Eclipse


With both the complexity of Java and the nuance of Eclipse, you can't be expected to remember everything. Sometimes, you need a little more help from Eclipse to get your programming going. Luckily, Eclipse offers both general and context-sensitive help:



  • For context-sensitive help: In Windows, press F1. In Linux, press Ctrl+F1. On a Mac, press Help.



  • For help that’s not context-sensitive: On the main menu bar, choose Help→Help Contents. The Help view appears. In the Help view’s Search field, type the words that you need help understanding. Press GO and wait for the To search the documentation, type a query. . . message to disappear. When at last the Search Results tab displays a list of pages, select a page. The page opens in the Help view’s browser pane.







>






>
dummies


Source:http://www.dummies.com/how-to/content/eclipse-for-dummies-cheat-sheet.html

No comments:

Post a Comment