Eclipse: Step-by-Step

Eclipse: Step-by-Step

by Joe Pluta
Eclipse: Step-by-Step

Eclipse: Step-by-Step

by Joe Pluta

eBook

$44.49  $58.99 Save 25% Current price is $44.49, Original price is $58.99. You Save 25%.

Available on Compatible NOOK devices, the free NOOK App and in My Digital Library.
WANT A NOOK?  Explore Now

Related collections and offers

LEND ME® See Details

Overview

Written for novice programmers who need to learn Eclipse, the new integrated, open-source development environment, this book covers three areas that are of crucial interest—Eclipse, IBM’s Software Widget Toolkit (the SWT), and JDBC. Questions such as how to use the new Eclipse Integrated Development Environment; how to create a complete functioning application with Eclipse; and where to get the software, how to install it, and how to configure it are answered. Options that programmers would use in a real production to be instantly productive in Eclipse and the steps needed to take to create a program or modifying an existing program are addressed.

Product Details

ISBN-13: 9781583477274
Publisher: MC Press, LLC
Publication date: 05/01/2012
Series: Step-by-Step series
Sold by: Barnes & Noble
Format: eBook
Pages: 362
File size: 11 MB
Note: This product may take a few minutes to download.

About the Author

Joe Pluta is a designer of distributed architectures for the midrange platform. His company, Pluta Brothers Design, develops tools that allow iSeries users to incorporate emerging technologies seamlessly into their legacy systems, providing a direct path to new architectures. He moderates the JAVA400-L mailing list and is a member of IBM's JTOpen core team. He is the author of the “Weaving WebSphere” column at mcpressonline.com and is a regular participant in mailing lists and newsgroups on topics surrounding the iSeries platform and Java in general. He lives in Palatine, Illinois.

Read an Excerpt

Eclipse: Step by Step

A Practical Guide to Becoming Proficient in Eclipse


By Joe Pluta

MC Press

Copyright © 2003 MC Press Online, LP
All rights reserved.
ISBN: 978-1-58347-727-4



CHAPTER 1

Step 1

Welcome to Eclipse!


Buckle your seat belts, because this is going to be one fast ride! In the pages that follow, you're going to learn not one, not two, but three of today's top Java technologies. Not only that, you'll learn how to put them together to create a real business application.

"Wait a minute," you say. "I don't even have Java on my machine!" Well, fear not. This book assumes nothing. Eclipse Step by Step walks you through downloading and installing every piece of software you need. The only requirement is that your PC has some horsepower and a bit of room on the disk.

That might look like a hefty machine, but if you plan to do development using today's generation of tools, that's a minimum. I prefer at least a gigabyte of RAM and a 2GHz processor, and I find 1280x1024 to be necessary if I plan to use the tools on a daily basis, but the specs I posted above are enough to get started. With some judicious shopping on the Internet, you can find a machine with those specifications for under $1000 USD.

Where the operating system matters, this book is going to assume a Windows machine. Screenshots throughout the book are from a Windows 2000 machine. However, Eclipse will run on other operating systems, notably Linux and Macintosh, with others available or in development. I've included the latest version of Eclipse for several platforms on the enclosed CD-ROM. Since Eclipse is a very highly integrated environment, there aren't many places where you have to go outside the box, so to speak, and interact directly with the operating system. The only steps that might be different are downloading from the Internet or importing files from the CD. Non-Windows users may need to adjust the scripts for those steps accordingly.

More importantly, Eclipse is designed to take on the look and feel of the host operating system, so non-Windows users will get a different look and feel than Windows users. In fact, there are two Linux versions: one for Motif and one for GTK. This is a fundamental concept of the design philosophy of Software Widget Toolkit (SWT), one of the underlying technologies of Eclipse and one of the topics this book will cover. Also, Eclipse is supported on the Mac only for OS X users; there are currently no plans for an OS9 implementation.

Several of the Sidesteps show you how to download various pieces of software from the Internet (all software used in this book — other than the Windows operating system — is freely available for download). The browser used in the download steps is Microsoft Internet Explorer version 6. This makes the download process a little different from previous versions of Internet Explorer and significantly different than other browsers. The thing to note is that I instruct the browser to open the files immediately once they are downloaded rather than save them to a folder on my disk drive. This is more of a convenience rather than a recommended practice. Whatever your current practices are for downloading software, please follow them. In particular, if you are working on a company machine, please follow your corporate security procedures.

Windows and Linux users need a Java virtual machine (JVM) — Sidestep 1 will help you download one if you do not already have one. Macintosh users have their own JVM, so they don't need this particular step. I've also included the SQL engine that the exercises use, HSQLDB. I like HSQLDB because it's a pure Java implementation, so it will run anywhere you have a JVM, with no additional installation considerations.

Finally, because some people may prefer other SQL engines or might prefer Swing over SWT, I've included Sidesteps on those particular topics to help you adapt these exercises to those technologies. If the previous sentence made no sense, then you probably don't have to worry about those Sidesteps!


How it works

The Step by Step books are very simple in format. The entire book is broken down into sequential steps. They are meant to be followed in order. Each Step will have a checklist. The checklist will look something like this:

[check] Here is your step checklist:

[] 1.1(a) Place toothpaste on the toothbrush

[] 1.1(b) Brush teeth vigorously for two minutes

(...)


The number on the left will refer to the step (1.1, 1.2, 2.1, and so on) and the task within that step (a, b, c, ...). The page number on the right refers to the page number where that particular task can be found.

Each step will start on a new page and will have a heading and a goal statement. There may be a paragraph or two of additional information as well. Each task will have detailed instructions and one or more associated illustrations (occasionally several tasks will refer to the same image, for example when filling out the fields of a dialog box).

Some of the steps may seem very simple, especially if you already have some experience in a given area, but I wanted to be sure not to leave anything out. If you follow all the steps to the letter, by the time you finish the book you will have completed the goal of creating a business application using Eclipse, SWT, and JDBC.

You'll notice that if there are several ways to do something (such as open a file), I may do it differently at different places in the book. This is to give you some exposure to the many ways Eclipse allows you to do things. Eventually you'll develop your own preferences as to how to do these things.


What I'll cover

Eclipse

The first big topic in the book is Eclipse. Indeed, that's probably the reason you bought the book — to learn how to use Eclipse. Eclipse is a huge application — a set of applications, really — and since it's an Open Source project, it's constantly evolving and growing. You'd literally need thousands of pages of documentation to keep up with everything, but as with all such applications, you will use only a small part of the entire application in your day-to-day activities.

Without any features added, Eclipse doesn't do much of anything. It is really just a common framework onto which you can attach tools. However, Eclipse comes with a couple of standard features. One is the Plug-In Development Environment (PDE), which we won't be covering in this book. The other is the Java Development Tooling, or JDT, which is our focus. The JDT is the standard Eclipse Java IDE.

The primary tasks for any IDE are managing, editing, compiling, and debugging code. In this book, you will:

1. Create a Java project

2. Enter source code and edit it

3. "Compile," run, and debug an application


I put the word compile in quotes, because the JDT automatically compiles source when you save it. It's important to remember, though, that Eclipse is not simply about Java development. The Java Development Tooling feature is just one of many features that can be added to Eclipse.

As you read this, people are working all over the world adding other features to Eclipse. These plug-ins will add all sorts of new capabilities, from support for additional languages to extra options such as Google searches or even an MP3 player.

And the wonderful thing about it is that if these features are written in the spirit of the Eclipse framework, then it will be easy for you to learn to use them, because you will already be familiar with Eclipse. In this book, you will learn the features that all Eclipse applications share and the common operations and actions that can be used with any well-designed Eclipse feature.


The Java Development Tools (or JDT)

While I will teach you the common aspects of the Eclipse environment, I do want this to be productive, and so most of your time in this book will be spent in the JDT. The JDT is as close to a "base plug-in" as you will get; the developers of Eclipse put a lot of work into the JDT. Each new release of Eclipse includes an updated JDT, and I think the JDT is one of the primary testing grounds for the SWT (which I'll get to in a moment).

The JDT is IBM's replacement for the Visual Age for Java IDE (which was, in my opinion, the best Java IDE available). It's no coincidence that one of the primary teams behind Eclipse and the JDT is a company called Object Technology Inc. (OTI), the same folks who brought you Visual Age for Java. This is a very bright, very innovative group of folks.


The Standard Widget Toolkit (or SWT)

One of the biggest innovations from the Eclipse team, an innovation that grew out of OTI's long experience with graphical interface design, is the Standard Widget Toolkit or SWT.

The JDT is the next generation of Visual Age for Java. One of the problems with VAJ was that it was pretty platform-specific. That was because it used a very complex and sophisticated UI. The OTI team figured out a way of combining the run-anywhere nature of Java with the performance of native GUI routines. While there is great debate over the architecture of this approach, there is no doubt that the SWT API allows the creation of some very powerful application code.

The SWT is different from other Java packages. First off, it requires a native piece — a DLL in Windows, a shared library in Linux. SWT won't run unless that piece is available. Second, much of the SWT has been designed to keep as small a footprint as possible. This has been done with the thought in mind that any program written for a larger machine should be able to be run on a portable. Thus SWT is designed to run on machines using Windows CE or similar micro edition operating systems.


JDBC and HSQLDB

Finally, once you've learned how to talk to the user via SWT (or Swing if you're so inclined), you need to talk to a database. Without this capability, a business program is largely useless. Step 10 deals specifically with accessing the database.

I've used HSQLDB, an Open Source 100% Pure Java SQL database engine, as the underlying database for this book. I did it because, of the many SQL engines I've worked with, HSQLDB required the least work during initial setup. Basically, it was unzip and go. However, you may want to use a different database. I've included instructions on some of the more popular free databases, such as PostGreSQL.

So, if you're ready, it's time to get started. Enjoy!

CHAPTER 2

Step 2


Installing Eclipse


Before you install Eclipse, your system must meet a few hardware and software prerequisites, and a couple of additional downloads are recommended. The hardware prerequisites for your machine were outlined in Step 1. The only additional requirements are the software — you must have a Java runtime environment and a ZIP file utility.

If you have a Macintosh, your Java runtime is built in. For Windows or Linux machines, you need to download one, but they are readily available. To do this, go to SideStep 1. Also, if you are running Microsoft Windows, I highly suggest the WinZip utility. If you do not already have this program, SideStep 2 shows you how to get it.

Finally, you can either use the Eclipse SDK version included on the CD-ROM or download the latest version. The release of this book was timed to include the final release of version 2.1 of Eclipse, released on March 28, 2003. Based on when you are reading this book, you may choose to download a later release rather than use the included software. In general, I'd say the CD version will be fine for at least a year (that is, until March 2004). After that (or if you enjoy seeing new features), I would recommend downloading a newer version. Information on downloading Eclipse from the Eclipse Web site is available in SideStep 3.

Once you've met these initial requirements and decided on which Eclipse version to use, you can continue on.

The following checklist can be used to make sure you have completed all the activities for this step.

[check] Here is your step checklist:

[] 2.1(a) Using the Windows Start button, start WinZip

[] 2.1(b) Click the Open button

[] 2.1(c) Select your CDROM drive

[] 2.1(d) Open the Software folder

[] 2.1(e) Open the Eclipse folder

[] 2.1(f) Open the Eclipse SDK ZIP file

[] 2.1(g) Click the Extract button

[] 2.1(h) Save the directory name as $ECLIPSEINST: ____

[] 2.1(i) Enter the value of $ECLIPSEINST as the directory and click Extract

[] 2.1(j) Close WinZip

[] 2.2(a) Locate the IDE

[] 2.2(b) Right-click the IDE icon and select Create Shortcut

[] 2.2(c) Start the IDE

[] 2.2(d) Wait for the IDE workbench to appear


Step 2.1 — Extract Eclipse

GOAL

In this step, you will install the Eclipse IDE from its ZIP file, either the one included on the CDROM or the one you downloaded in SideStep 3.

[] 2.1(a) Using the Windows Start button, start WinZip.

[] 2.1(b) Click the Open button.

Now, you need to select the file. I will walk you through the steps to open the ZIP file included on the CDROM. If, however, you've downloaded a different version of Eclipse using SideStep 3, you'll need to navigate to that file instead.

[] 2.1(c) Select your CDROM drive.

[] 2.1(d) Open the Software folder.

[] 2.1(e) Open the Eclipse folder.

[] 2.1(f) Open the Eclipse SDK ZIP file.


You will see the ZIP file contents as shown in Figure 2.7.

[] 2.1(g) Clickthe Extract button.


Clicking the Extract button will bring up a dialog box that allows you to select a directory to install the ZIP contents into. This dialog will look like the one in Figure 2.9.

You now need to decide where to install this software. I prefer to use "C:\Program Files", because the IDE is after all a program. Everything in the ZIP file is actually in a folder called "eclipse" or one of its subfolders, so after you've finished, you'll see a folder named "eclipse" under "C:\Program Files". Also be sure that the checkbox marked "Use folder names" is checked; otherwise the extract process will not build the required directory structure.

[] 2.1(h) Save the directory name as $ECLIPSEINST:.

[] 2.1(i) Enter the value of $ECLIPSEINST as the directory and click Extract.


A status dialog like the one in Figure 2.10 will come up to show you the progress of the extraction.

Once this finishes, you have successfully installed Eclipse. Time to run it. First, close WinZip, either by selecting the File menu and then selecting the Exit option or by clicking on the X in the upper right corner of the WinZip window.

[] 2.1(j) CloseWinZip.


Step 2.2 — Run Eclipse

GOAL

In this step, you will run the Eclipse IDE.


[] 2.2(a) Locate the IDE.

Unlike many Windows programs, Eclipse does not automatically add an option to the Start button. Instead, to start the IDE, you first need to navigate to the correct folder using Windows Explorer, as shown in Figure 2.12.

At this point, you may want to make a shortcut icon that you can place either on your desktop or in your start menu. Personally, I use the Microsoft Office quick launcher. I just drop the icon on the bar and it's there for me whenever I need it.


[] 2.2(b) Right-click the IDE icon and select Create Shortcut.

A new icon will appear, which will look exactly like the IDE icon, but with an arrow on the bottom left indicating that this is a shortcut. You can now move this shortcut icon wherever you want to allow easy access to the program.


[] 2.2(c) Start the IDE.

[] 2.2(d) Wait for the IDE workbench to appear.

On the machine used for this book, a 1.6GHz Pentium 4, the splash screen stayed up for about 12 seconds. Then the screen shown in Figure 2.17 appeared.

CHAPTER 3

Step 3


Introducing the workbench


Everything in Eclipse is done through the workbench. The workbench is sort of your view on the world. In this step, I'm going to introduce you to it.

First, I'll point out the different parts of the workbench. Then I'll show you the Eclipse Workbench User Guide, an in-depth guide to the features of the workbench. This is an excellent reference document.

In the next step, we will learn more about the components and how to use them.


(Continues...)

Excerpted from Eclipse: Step by Step by Joe Pluta. Copyright © 2003 MC Press Online, LP. Excerpted by permission of MC Press.
All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.

Table of Contents

Contents

Foreword,
Chapter 1 Welcome to Eclipse!,
Chapter 2 Installing Eclipse,
Chapter 3 Introducing the workbench,
Chapter 4 The Resource perspective,
Chapter 5 The Java perspective,
Chapter 6 The Debug perspective,
Chapter 7 A simple program,
Chapter 8 Running and debugging,
Chapter 9 The user interface,
Chapter 10 Adding the database,
SideStep 1 Install a Java runtime,
SideStep 2 Install Winzip,
SideStep 3 Download Eclipse,
SideStep 4 On things GUI,
SideStep 5 Start your SQL engines,
Index,

From the B&N Reads Blog

Customer Reviews