DekGenius.com
Previous Section  < Day Day Up >  Next Section

13.2 Creating a Java Project

For Java programmers, the fundamental Eclipse task is creating a Java project. As you're going to see, the process is (so far) virtually identical to working in Eclipse 2.1.

To create a new project, right-click the Navigator view and selectNew Project, opening the New Project dialog. Select the Java item in the pane on the left and Java Project in the pane on the right and click Next. These dialogs you see in Figure 13-2 are just as we've seen before. Name this new project Ch13_01 and click Next.

Figure 13-2. Naming the new project
figs/ecps_1302.gif

This brings up the familiar dialog you see in Figure 13-3, where you can set project settings, such as the source folder and the import and export order—all items we're already familiar with. Click Finish to create the project.

Figure 13-3. Setting project options
figs/ecps_1303.gif

Eclipse 3.0 will ask if you want to switch to the Java perspective; click OK. The new Java perspective looks much like what we've seen before, except that the Tasks view has now been renamed the Problems view, as you see in Figure 13-4.

Figure 13-4. The Eclipse 3.0 Java perspective
figs/ecps_1304.gif

To create a new class, right-click the project and select New Class, opening the New Java Class dialog you see in Figure 13-5. This is the same dialog we've worked with throughout this book, so just enter the new class's name, Ch13_01, and package, org.eclipsebook.ch13, and click Finish.

Figure 13-5. Creating a new class
figs/ecps_1305.gif

Opening the new Java file in the Java editor reveals some changes—for example, the new shape of the cursor, as you see in Figure 13-6. That's the smart insert cursor, which is covered a little later in this chapter—see Section 13.4.4. Note also the two new buttons in the Outline view—Hide Local Types and Link With Editor.

Figure 13-6. Using the Java editor
figs/ecps_1306.gif

At left in the new JDT editor is the Quick Diff bar, which lets you track differences to particular lines as compared to what's been saved on disk (or, if you configure it, to what's in a CVS repository).

To see how Quick Diff works, enter System.out.println("Hello"); in the main method, and save the file (only the Save diskette icon appears in the toolbar now, not the Save All diskette icon). Next, change the line to System.out.println("Hello from Eclipse 3.0"); and let the mouse hover over the Quick Diff bar as you see in Figure 13-7. The original version of the code will appear, and you can restore it by clicking it.

Quick Diff is also being made available to plug-ins.


Figure 13-7. Using Quick Diff
figs/ecps_1307.gif

To run this code, select Run Run As Java Application (note the new Run Run As JUnit Plug-in Test menu item as well), giving the results you see in the Console view in Figure 13-8. That's it; you've created and run a Java application in Eclipse 3.0. As you can see, the procss is very similar to what you would see in Eclipse 2.1.

Note the new buttons in the Console view: Pin Console, Display Selected Console, and Remove All Terminated Launches.


Figure 13-8. Running the code
figs/ecps_1308.gif

That recreates a familiar task for us in Eclipse 3.0, and, as you can see, it works much as we've seen before.

Perhaps the biggest change in Version 3.0 is that the Eclipse platform has been broadened for use as a general hosting tool, designed to work with general applications, not just IDEs. Now general applications will be able to populate the menu bar and toolbars, and the assumed data model will no longer be necessarily centered on the workspace. We'll be seeing more on that as Eclipse 3.0 nears launch.

There are also specific changes to the various parts of Eclipse—the Eclipse platform itself, the JDT, SWT, and so on—and we'll examine them on a case-by-case basis.

    Previous Section  < Day Day Up >  Next Section