Thông tin tài liệu
www.it-ebooks.info
www.it-ebooks.info
Eclipse
www.it-ebooks.info
Other Java
™
resources from O’Reilly
Related titles
Java
™
in a Nutshell
Head First Java
™
Head First EJB
™
Programming Jakarta Struts
Tomcat: The Definitive Guide
Learning Java
™
Java
™
Extreme Programming
Cookbook
Java
™
Servlet and JSP
™
Cookbook
™
Hardcore Java
™
JavaServer
™
Pages
Java Books
Resource Center
java.oreilly.com is a complete catalog of O’Reilly’s books on
Java and related technologies, including sample chapters and
code examples.
OnJava.com is a one-stop resource for enterprise Java develop-
ers, featuring news, code recipes, interviews, weblogs, and
more.
Conferences
O’Reilly & Associates brings diverse innovators together to nur-
ture the ideas that spark revolutionary industries. We specialize
in documenting the latest tools and systems, translating the in-
novator’s knowledge into useful skills for those in the trenches.
Visit conferences.oreilly.com for our upcoming events.
Safari Bookshelf (safari.oreilly.com) is the premier online refer-
ence library for programmers and IT professionals. Conduct
searches across more than 1,000 books. Subscribers can zero in
on answers to time-critical questions in a matter of seconds.
Read the books on your Bookshelf from cover to cover or sim-
ply flip to the page you need. Try it today with a free trial.
www.it-ebooks.info
Eclipse
Steve Holzner
Beijing
•
Cambridge
•
Farnham
•
Köln
•
Sebastopol
•
Taipei
•
Tokyo
www.it-ebooks.info
Eclipse
by Steve Holzner
Copyright © 2004 O’Reilly Media, Inc. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly Media, Inc. books may be purchased for educational, business, or sales promotional use.
Online editions are also available for most titles (safari.oreilly.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.
Editor:
Brett McLaughlin
Production Editor:
Marlowe Shaeffer
Cover Designer:
Ellie Volckhausen
Interior Designer:
David Futato
Printing History:
April 2004: First Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. The title of Eclipse, the images of ornate butterflyfish, and related trade dress are
trademarks of O’Reilly Media, Inc.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun
Microsystems, Inc., in the United States and other countries. O’Reilly Media, Inc. is independent of Sun
Microsystems, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information
contained herein.
This book uses RepKover
™
, a durable and flexible lay-flat binding.
ISBN: 978-0-596-00641-9
[C] [6/09]
www.it-ebooks.info
v
Table of Contents
Preface
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ix
1. Essential Eclipse
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
Eclipse and Java 1
Getting Eclipse 4
Understanding Eclipse 6
Views and Perspectives 9
Working with Eclipse 11
Using Quick Fix 22
A Word About Project Management 25
2. Java Development
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
28
Developing Java Code 28
Building and Running Code 39
Creating Javadoc 46
Refactoring 47
Some Essential Skills 54
Customizing the Development Environment 57
3. Testing and Debugging
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
64
Testing with JUnit 64
Debugging 74
4. Working in Teams
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
93
How Source Control Works 93
Understanding CVS 93
Finding a CVS Server 95
Adding a Project to the CVS Repository 96
www.it-ebooks.info
vi | Table of Contents
5. Building Eclipse Projects Using Ant
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
115
Working with Ant 115
JARing Your Output 118
Configuring Ant in Eclipse 124
Catching Errors in Build Files 127
6. GUI Programming: From Applets to Swing
. . . . . . . . . . . . . . . . . . . . . . . . . . .
130
Creating AWT Applications 133
Creating Swing Applications 135
Using Eclipse Plug-ins 142
Using the V4ALL Plug-in 142
7. SWT: Buttons, Text, Labels, Lists, Layouts, and Events
. . . . . . . . . . . . . . . . .
149
Java Graphics 149
An SWT Example 150
Working with Buttons 158
Working with Composites and Layouts 163
Working with Lists 165
Using V4ALL with SWT 167
8. SWT: Menus, Toolbars, Sliders, Trees, and Dialogs
. . . . . . . . . . . . . . . . . . . . .
170
Working with Menus 170
Working with Toolbars 175
Working with Sliders 179
Working with Trees 183
Working with Dialogs 186
Opening Internet Explorer in an SWT Window 191
9. Web Development
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
195
Installing and Testing Tomcat 195
Creating a JSP 197
Creating a Servlet 199
Creating a Servlet in Place 202
Connecting to a JavaBean 205
Using the Sysdeo Tomcat Plug-in 207
Deploying Web Applications 215
www.it-ebooks.info
Table of Contents | vii
10. Developing Struts Applications with Eclipse
. . . . . . . . . . . . . . . . . . . . . . . . . .
219
Struts and Eclipse 219
Creating the View 222
Creating the Controller 225
Creating the Model 229
Using the Easy Struts Plug-in 234
11. Developing a Plug-in: The Plug-in Development Environment,
Manifests, and Extension Points
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
242
All You Really Need Is plugin.xml 243
Using the Plug-in Development Environment 244
Using the Run-time Workbench 248
Creating a Standard Plug-in 250
12. Developing a Plug-in: Creating Editors and Views
. . . . . . . . . . . . . . . . . . . . .
261
Creating a Multi-Page Editor 261
Creating a View 269
Deploying a Plug-in 275
13. Eclipse 3.0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
278
A Look at Eclipse 3.0 278
Creating a Java Project 279
Changes to the Eclipse Platform 282
Changes to the Java Development Tools 288
Other Changes 295
Index
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
297
www.it-ebooks.info
www.it-ebooks.info
[...]... versions of Eclipse? See http://www .eclipse. org /eclipse/ development/main.html Installing Eclipse is not difficult—all you’ve got to do is unzip or untar it, depending on your operating system Since you’ve downloaded the version of Eclipse targeted to your operating system, you’ll find the executable file ready to run as soon as you uncompress Eclipse Windows users will be pleased to learn that Eclipse. .. about: Eclipse You can see Eclipse in action in Figure 1-1 Eclipse and Java Although Eclipse can act as an IDE for many different languages—IDEs are available from C/C++ to Cobol—its great popularity is as a Java IDE, and it comes with Java support built-in Eclipse refers to itself as a universal tool platform, capable of handling IDEs for many different languages, but the Java IDE that comes with Eclipse. .. the Internet for free You’ll need Eclipse this book was written using Eclipse 2.1.1—and we’ll discuss where to get Eclipse in Chapter 1 Other software packages that we’ll be downloading throughout the book include the Tomcat web server and various CVS servers (which will allow you to share Eclipse projects with others) Eclipse is built to be extendible, and hundreds of Eclipse plug-ins are available for... reserved 5 Understanding Eclipse So what is Eclipse itself? Most people think of Eclipse as a Java IDE, and when you download Eclipse, you get the Java IDE (this is the Java Development Toolkit, the JDT) and the Plug-in Development Environment (the PDE) with it If you only want to develop Java, it’s easy to think of Eclipse as a Java IDE because that’s the main tool you’ll be using Eclipse itself, however,... overview—let’s get this show on the road Getting Eclipse How do you get and install Eclipse? Eclipse is free for the downloading—all you have to do is navigate to http://www .eclipse. org/downloads and select one of the download mirrors available on that page When you do, you’ll be presented with a list of the available downloads, which are of these types: Release builds The Eclipse team releases these versions... There’s as much Eclipse crammed into this book as you need to master the topic, and mastering Eclipse is our goal What’s Inside From cover to cover, this book is pure Eclipse, covering hundreds of skills and techniques We start from the most basic Java development and work up to creating your own plug-in editors for the Eclipse environment Here are a few of the topics in this book: • Using Eclipse to develop... registry, so (re)installation is easy and trouble free You start Eclipse by running the Eclipse executable, such as eclipse. exe When you start the program the first time, it may ask you to wait while it completes the installation, which does not take long (Eclipse is creating the workspace directories it’ll be using) When you first run Eclipse, you should see something like Figure 1-1, shown earlier... starting Eclipse easier, you can also connect various shortcuts to the Eclipse executable In Windows, right-click the executable file in the Windows Explorer and select “Create Shortcut” from the context menu that opens, then drag the new shortcut where you want it In Linux or Unix, just add the Eclipse directory to your path, or use ln -s to create a symbolic link to the Eclipse executable Getting Eclipse. .. Chapter 5, Building Eclipse Projects Using Ant Ant is a powerful Java build tool, and we’ll see in this chapter that you can do things with Ant in Eclipse that Eclipse can’t do alone, such as copy and move files Chapter 6, GUI Programming: From Applets to Swing This chapter starts our work using Eclipse to handle GUI development with Swing We’ll also take a look at a Swing plug-in for Eclipse here—using... architecture The Eclipse Workbench The Eclipse workbench is what you saw back in Figure 1-1—it’s the basic graphical interface you work with when you use Eclipse It’s got all kinds of toolbars and menus for you to use, and its job is to present those items and the internal windows you saw in Figure 1-1 Next to the platform kernel, the workbench is Eclipse at its most basic When you start Eclipse, before . is the one this book is all about: Eclipse. You can see
Eclipse in action in Figure 1-1.
Eclipse and Java
Although Eclipse can act as an IDE for many different. road.
Getting Eclipse
How do you get and install Eclipse? Eclipse is free for the downloading—all you have
to do is navigate to http://www .eclipse. org/downloads
Ngày đăng: 18/03/2014, 02:20
Xem thêm: eclipse pdf, eclipse pdf