UNPKG

epubjs

Version:

Render ePub documents in the browser, across many devices

44 lines (43 loc) 6.2 kB
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><title>Configuring Eclipse and Creating a Project</title><link rel="stylesheet" href="core.css" type="text/css"/><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"/></head><body><div class="sect1" title="Configuring Eclipse and Creating a Project"><div class="titlepage"><div><div><h1 class="title"><a id="I_sect12_id636001"/>Configuring Eclipse and Creating a Project</h1></div></div></div><p><a id="idx10055" class="indexterm"/> <a id="idx10058" class="indexterm"/> <a id="idx10059" class="indexterm"/> <a id="idx10106" class="indexterm"/> <a id="I_indexterm2_id636051" class="indexterm"/>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 application’s folder itself, which is probably not what you want. Choose a location and click OK.</p><p>Eclipse greets you with the Welcome screen. Close this window by closing the Welcome tab within the application. If you want to come back later and go through the Eclipse tutorials and related help topics, you can return to this window by choosing Help <span class="unicode"></span> Welcome.</p><p>One last thing before we move on: Eclipse stores all of its configuration information in the <span class="emphasis"><em>configuration</em></span> 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 application 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 application windows to their default locations, you can choose Window <span class="unicode"></span> Reset Perspective. We’ll talk more about perspectives later.</p><p>We are going to create a project to hold all our examples. Select File <span class="unicode"></span> New <span class="unicode"></span> Java Project from the application menu and type <strong class="userinput"><code>Learning Java</code></strong> in the “Project name” field at the top of the dialog, as seen in <a class="xref" href="ch02s02.html#learnjava4-CHP-2-FIG-1" title="Figure 2-1. New Java Project dialog">Figure 2-1</a>. Make sure the JRE version is set to JavaSE-1.7 as seen in the figure and click <span class="emphasis"><em>Next</em></span> at the bottom.</p><div class="figure"><a id="learnjava4-CHP-2-FIG-1"/><div class="figure-contents"><div class="mediaobject"><a id="I_2_tt16"/><img src="httpatomoreillycomsourceoreillyimages1707599.png.jpg" alt="New Java Project dialog"/></div></div><p class="title">Figure 2-1. New Java Project dialog</p></div><p>Next, you will need to set your build path to the Java 7 system library. Select the <span class="emphasis"><em>Libraries</em></span> tab and remove the Java 1.6 library. Click <span class="emphasis"><em>Add Library</em></span> and select JavaSE-1.7. Eclipse is now configured to use Java 7. Click <span class="emphasis"><em>Finish</em></span>.</p><div class="sect2" title="Importing the Learning Java Examples"><div class="titlepage"><div><div><h2 class="title"><a id="id842435"/>Importing the Learning Java Examples</h2></div></div></div><p>Let’s load the examples from this book. You can find a ZIP file containing all of the examples from this book nicely packaged as an Eclipse project at <a class="ulink" href="http://oreil.ly/Java_4E">http://oreil.ly/Java_4E</a>. The Eclipse version of the examples is called <em class="filename">examples-eclipse.zip</em>. (The file <em class="filename">examples.zip</em> holds the same examples but packaged slightly differently and without the Eclipse project files.)</p><p>Next, we’ll import the examples ZIP file. Choose File <span class="unicode"></span> Import to open the Import wizard. Select Archive File as the source and click <span class="emphasis"><em>Next</em></span>. See <a class="xref" href="ch02s02.html#learnjava4-CHP-2-FIG-2" title="Figure 2-2. New Java Project dialog">Figure 2-2</a>.</p><div class="figure"><a id="learnjava4-CHP-2-FIG-2"/><div class="figure-contents"><div class="mediaobject"><a id="I_2_tt16_2"/><img src="httpatomoreillycomsourceoreillyimages1707600.png.jpg" alt="New Java Project dialog"/></div></div><p class="title">Figure 2-2. New Java Project dialog</p></div><p>Click the Browse button and choose the <em class="filename">examples-eclipse.zip</em> file as seen in <a class="xref" href="ch02s02.html#learnjava4-CHP-2-FIG-3" title="Figure 2-3. New Java Project dialog">Figure 2-3</a>. Check the “Overwrite existing resources without warning” button so that our Eclipse-specific project file will overwrite the empty one in your new project. Click <span class="emphasis"><em>Finish</em></span>.</p><div class="figure"><a id="learnjava4-CHP-2-FIG-3"/><div class="figure-contents"><div class="mediaobject"><a id="I_2_tt16_3"/><img src="httpatomoreillycomsourceoreillyimages1707601.png.jpg" alt="New Java Project dialog"/></div></div><p class="title">Figure 2-3. New Java Project dialog</p></div><p>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). On the left is the Package Explorer. It shows a tree view of the Java packages, libraries, and resources of our project. Click the folder handles to expand the tree and see source folders for each chapter in the book. Now we are ready to start coding!<a id="I_indexterm2_id636262" class="indexterm"/><a id="I_indexterm2_id636270" class="indexterm"/><a id="I_indexterm2_id636277" class="indexterm"/><a id="I_indexterm2_id636284" class="indexterm"/></p></div></div></body></html>