You may either enter the code directly into the editor or use the Import feature to import the source from the supplied CD-ROM. If you wish to enter the source yourself and get a feel for the source editor, use Option I below. Otherwise, skip ahead to Option 2.
q 7.4(a) Enter the following source code as your main() method.
System.out.println("Hello World!"); System.exit(0);
q 7.4(b) Right-click in the editor pane and select Save.
Another option is just to press Ctrl-S. At this point, you can skip ahead to Step 7.5. However, you might want to execute Option 2 anyway. This will import the code from the CD-ROM and overwrite the code you just entered. It will look exactly the same as what you typed in except for the author name , and you'll learn how to use the Import feature, which I'm sure you'll be using in the future.
Importing is quite easy. The only part that can get a little confusing is the relationship between folders and packages. When you are importing from a file system, you must be certain to import from the correct point in the file tree. To make it easy for this book, I have located the source for each step in a folder named for that step, as you are about to see.
q 7.4(c) Insert the included CD-ROM into your CD-ROM drive.
q 7.4(d) Right-click on the Hello project and select Import ...
The Import wizard gives you several options for your import source. Since your source is in a folder on the CD-ROM, you'll use the File system option.
q 7.4(e) Select File system in the Import wizard and click Next.
Now you need to specify the location of the files. All source for this step is located on the CD-ROM in a folder called Source, in a subfolder called Step 7, so specify R:\Source\Step 7, where R is the letter of the CD-ROM drive where you loaded the disk. In Figure 7.15, the disk is loaded in the D: drive.
q 7.4(f) Enter "R:\Source\Step 7" in the From directory field, where R is the drive letter of your CD-ROM drive, and press the Tab key.
The Tab key will cause the left pane to display an icon for the Step 7 folder. Select the Step 7 folder by clicking on it.
q 7.4(g) Left-click on the Step 7 folder.
This will cause the contents of the Step 7 folder to appear in the right-hand pane as shown in Figure 7.17.
Select HelloWorld.java by clicking on its checkbox.
q 7.4(h) Select HelloWorld.java and click Finish.
If you also performed Option 1, you will get a confirmation dialog like the one in Figure 7.19.
q 7.4(i) Click Yes on the confirmation box that pops up.
When you are done, your display should look just like the one shown in Figure 7.20. Since the source on the CD doesn't have all the fancy auto-generated comments, it'll be a little more austere than what the tool generated, as you can see.