As you add more plug-ins to your workbench, you will find that you have more and more options. For example, the base Eclipse Platform allows you to create projects only of a very simple type. The JDT and the PDE both add their own project types. The JDT adds the type Java Project. [1]
Note | This feature, like so many others, is configurable. Use the Windows/Preferences option, then on the Workbench/Perspectives page check or uncheck "Switch to recommended perspective" under "New project options" to enable or disable this auto-switch feature. |
Let's take the shortcut, shall we?
Okay, now you've got a nice clean workbench, so it's time to create a new project (and get things all messy again!). Remember that the right button of the mouse brings up context-sensitive popup menus .
q 5.2(a) Right-click on the Navigator pane and select New/Project...
Use the New Project wizard to select the type of project you are creating. For more complex projects, you may be asked for more information, but for a basic Java project, it's pretty simple.
q 5.2(b) Select Java on the left, select Java Project on the right, and click Next.
Enter the name and click Finish.
q 5.2(c) Type in 'Hello' and click Finish.
A prompt will come up, asking you if you want to switch perspectives. Click the "Don't show me this message again" box and then click Yes.
q 5.2(d) Check 'Do not show this message again' and click Yes.
You should notice a couple of things. First, a new Hello project is shown in the left-hand pane. If you examine the title bar, you'll see that you're no longer in the Resource perspective but have been switched to the Java perspective. Notice also that the Outline pane has moved from the lower left of the workbench to the upper right. Finally, you'll see that a new icon has appeared in the perspective bar on the left of the workbench, and that new icon (the Java perspective icon) is selected.
Now, take a look at the contents of the newly created Hello project.
q 5.2(e) Expand the Hello project.
You'll see that the project doesn't contain much. However, it isn't quite empty, either. This is how Eclipse plug-ins work; they can preload your projects with things that are needed. If you decide to build your own plug-ins, you'll be able to do the same thing, and customize the projects specifically to your environment. In the case of the JDT plug-in, a new Java Project is preloaded with a classpath containing the current Java runtime JAR file.
It's difficult to see the full name of the JAR file because of the size of the pane and the length of the path to the JVM.
q 5.2(f) Roll your cursor over the runtime JAR file.
When you roll your cursor over the JAR file, the full file name shows up in a tool tip. This JAR file was selected when you installed Eclipse. As with so many other things in Eclipse, you can change this default by going into the Preferences (use the Window/Preferences option from the main menubar). For this course, the default is fine.
Before going on, collapse the project again. It's a little exercise, and it makes the display a little less cluttered.
q 5.2(g) Collapse the project.
[1] The PDE adds several other project types, but you don't have to worry about those in this book. When you create a new Java Project, Eclipse will automatically switch to the appropriate perspective, which happens to be the Java perspective, the one we'll be concentrating on in this book. So, you could either switch to the Java perspective yourself manually and then create a new Java Project, or follow the actions in this step to take a shortcut.