Eclipse workspace and Project

Source: Internet
Author: User

Address: http://hi.baidu.com/china8jie/blog/item/c4bbe31f75b9ce64f724e4d2.html

Compare projects and workspaces

Eclipse organizes source code through concepts of projects and workspaces. A workspace is a collection of projects. A project is a collection of source code files. In general, the concept of workspace and project creates a lot of confusion in the novice, because the definition of project in eclipse is different from that in other ide projects.

Consider a project as an independent module and a workspace as a project. This is a good way to consider these concepts from the perspective of software development. Therefore, you have a project that contains multiple modules (projects in eclipse terminology) (workspace in eclipse terminology ). The following sections detail each concept.

Workspace

A workspace contains all items and settings, such as the color and font size used for syntax highlighting. You cannot work outside the eclipse workspace. When eclipse is started for the first time, it will prompt you to set the default location of the workspace. By selecting File> switch workspace> other, you can create a workspace or switch to another workspace. In the displayed dialog box, you can enter a location for an existing workspace or another location to create a new workspace. This dialog box also provides the option to copy the settings to the new workspace. However, this statement is incorrect because this option only copies the window layout and working set, instead of the highlighted color and font size template of the syntax. You may want to copy all these settings to the new workspace because it is very painful to reconfigure many settings that have already been configured in the current workspace. Fortunately, eclipse provides an easy way to copy all the settings to a new Workspace:

  1. Select File> export.
  2. In the displayed dialog box, select general> preferences and click Next.
  3. Select export all, provide the path of the file shown in figure 4, and click Finish. All settings of the workspace will be saved to the specified file.
  4. Switch to the new workspace, select File> import, and then select general> preferences.
  5. Point to the file you just saved and click Finish. Your settings will be imported into the new workspace.

Figure 4. Create or switch a workspace

The. Metadata directory in the workspace directory contains all the settings of each plug-in storage in eclipse. The existence of this directory tells eclipse that the current directory is a valid workspace .. The metadata directory also contains files named after. log. This file contains all the errors or exceptions that may be thrown when running eclipse. If eclipse crashes unexpectedly at a moment, this file will be very useful for error diagnosis.

Project

Projects in eclipse terminology can be independent applications or modules, depending on how you choose to organize your workspace. To create a new Java project, select File> New> project. In the displayed dialog box, select Java> JAVA project.

Many new users will be confused by the Project Name text box in this dialog box (see figure 5 ). You can use this box to filter the list of different types of projects, rather than named projects. Select the Java project item from the tree and click Next to go to the next step in the Wizard. Here, you can name a project and configure its settings.

Figure 5. Create a Java Project

The JRE group in the center of the create Java project dialog box allows you to select the Java version used to build this project. The project layout group indicates whether to put both the source code file and the generated class file in a folder or separate the files in a separate folder. We recommend that you retain the default settings: create separate folders for sources and class files. This separates the code from the generated binary file. Click Finish, and a new folder with the same name as the project will be created in the workspace directory. The project folder contains two folders named SRC and bin used to save the source code file and class file respectively. You will work in the SRC folder. eclipse will manage the bin folder to automatically generate class files in the background.

Custom toolbar and menu

You can customize the toolbar and menu bar at the top of the eclipse window as needed. The toolbar and menu bar are both configured based on the perspective. A perspective is a method for eclipse to Group views, toolbar, and menu la s based on the specific task you want to execute. For example, by default, eclipse has a perspective named Java and debug, which are used for Java code development and debugging respectively. The debug perspective has a view and toolbar button dedicated for debugging. These are not available in the Java perspective. You can switch the perspective by selecting WINDOW> open perspective> other or clicking the rightmost button on the toolbar.

Figure 6. Use the button on the right of the toolbar to switch the Perspective

To customize the toolbar and menu of the perspective, right-click the main toolbar at the top, select customize perspective, and click the commands tab. Menu/toolbar items are grouped by function, as shown in figure 7. For example, you can select search list items to enable search-related menus and toolbar items (eclipse calls the toolbar and menu items a command, just like the command sent to ide; therefore, tab label is commands, and the command group can be enabled/disabled ).

Figure 7. Custom toolbar and menu bar items

Customize eclipse preferences

Eclipse is a large complex ide with many plug-ins, and it provides a large number of customizable options. Fortunately, you can find all this content in a set. Select WINDOW> preferences to open the preferences dialog box.

Figure 8. preferences dialog box

This dialog box contains question mark ?? A large customizable option tree. Sometimes it is difficult to remember the exact location of the settings to be changed. Fortunately, you can type a text field at the top to filter the huge option tree. For example, if you type fonts in the box, the tree will be filtered immediately to display only font-related items. The next section describes how to change some common settings.

Change font

Select General> appearance> colors and fonts (see figure 9 ). Here, you can change the font of each part of the eclipse UI. For example, to change the font of the Java Editor, perform the following operations:

  1. In the preferences dialog box, select Java> JAVA editor text font.
  2. Click Change.
  3. Select the font and size.
  4. Click Apply.

Figure 9. Change the font

Change keyboard shortcuts

In the preferences dialog box, select general> keys (see figure 10 ). Here, you can set/change the keyboard shortcuts for each eclipse command. For example, to change the shortcut key of the Step over command, perform the following operations:

  1. In the text field, type step over.
  2. Select the step over command in the filtered list.
  3. In the binding box, press the new keyboard shortcut. Note that you do not need to enter the shortcut key-just press the button. For example, to assign the F2 key to the command, press the F2 key.
  4. If the new shortcut key conflicts with any existing shortcut key, it is displayed in the conflicts list.
  5. After changing the shortcut key, click OK.

Figure 10. Change the keyboard shortcut

Conclusion

You have carefully checked all the parts of Eclipse IDE. Now I know what the eclipse workbench and its components are. Understand what the workspace and project are, the differences between the two, and the relationship between the two. You also know how to customize each part of the IDE as needed and how to export these settings from one workspace to another. Section 2nd describes how to use the Java project and eclipse Java Development Environment (jdt ).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.