A.2. Getting Started with Eclipse

Let's get started. First, you'll need to install Eclipse. You can get Version 3.1 from the CD accompanying this tutorial or you can download the latest version from http://eclipse.org/. Simply unpack the zip file to a location of your choice and then launch the app. The first time you run Eclipse you'll be prompted to select a workspace. This is a root directory to hold new projects that you create within Eclipse. The default location is inside the app's folder itself, probably not what you want. Pick a location and click OK. Eclipse greets you with the Welcome Screen. Close this window by closing the Welcome tab within the app. If you want to come back later and go through the Eclipse tutorials and related help topics, you can get this window back by choosing Help Screenshot Welcome. One last thing before we move on: Eclipse stores all of its configuration information in the configuration folder inside the Eclipse installation directory. If, at any point in this introduction, you feel that things are not right and you want to start from scratch, you can quit the app and remove this folder. You may also wish to remove your workspace items as they hold per-project state. Less drastically, if you wish to reset all of the app windows to their default locations, you can choose Window Screenshot Reset Perspective. We'll talk more about perspectives later.

A.2.1. Importing the Learning Java Examples

Before we talk about the IDE itself, let's load the examples from this tutorial. You can find a ZIP file containing all of the examples from this tutorial nicely packaged as an Eclipse project on the CD accompanying this tutorial or at http://www.oracle.com/catalog/learnjava3. The Eclipse version of the examples is called examples-eclipse.zip. (The file examples.zip holds the same examples but packaged slightly differently and without the Eclipse project files.) First, create a new project to hold the examples using the File Screenshot New Project menu item. In the New Project wizard, select Java Project as the project type and click Next. Give the project a name (we used LearningJava). The default location for the project folder will be in the workspace area that you designated earlier, but you can change this if you wish. Click Finish when you're done. (If Eclipse asks if you wish to set the "project compliance settings" to Java 5.0, you should answer Yes.) Next, we'll import the examples zip file. Choose File Screenshot Import to open the Import wizard. Select Archive File as the source and click Next. Click the Browse button and choose the eclipse-examples.zip file. Check the "Overwrite existing files without warning" button so that our Eclipse-specific project file will overwrite the empty one in your new project. The Import wizard should look like Screenshot A-1 (we've expanded the folder tree so that you can see the examples). Click Finish. Eclipse will now import all of the files from the archive and immediately begin building the source in the background (a small progress bar at the bottom of the screen will show this).