Save 40% on books and eBooks + 70% on videos now through May 31*—use code PROGRAM. Shop now.
"This book does an excellent job of helping you learn Eclipse. The practical examples and exercises included have been proven in real-life course situations and are invaluable in helping you to get up and running quickly."
—Dave Thomson, Eclipse Project Program Director, Object Technology International, Inc.
Eclipse is a world-class Java IDE, a platform for building and integrating application development tools, and an open source project and community. Written by members of the IBM Eclipse Jumpstart team, The Java™ Developer's Guide to Eclipse is the definitive Eclipse companion. Drawing on their considerable experience teaching Eclipse and mentoring developers, the authors provide guidance on how to customize Eclipse for increased productivity and efficiency and how to avoid common pitfalls.
Key coverage includes:
Those new to Eclipse will benefit from the directed exercises on using the Eclipse platform. Advanced developers can learn how to extend Eclipse and use this book as a reference to the Eclipse frameworks.
The accompanying CD-ROM contains Eclipse SDK Version 2.0, as well as exercise solutions and many code examples for easier learning. Whether you want to use Eclipse and Eclipse-based offerings as your integrated development environment (IDE), or customize Eclipse further, this book is your definitive reference.
Download Sample Chapter 3 related to this title.
Origin of the Book.
Intended Audience and Prerequisites.
How the Book Is Organized.
I. RUNNING ECLIPSE.1. Getting Started.
Software Challenge and Eclipse.
What Is Eclipse?
Java Development Environment.
Tool Integration Platform.
Open Source Community.
What Is the Common Public License?
Getting and Installing Eclipse.
The Eclipse Look: Editors, Views, and Perspectives.
Working in Eclipse.
A Word to IBM VisualAge Users.
References.2. Using Eclipse.
Creating Your First Project.
Overview of the User Interface.
Manipulating the User Interface.
Fundamental Eclipse Use.
Working with Tasks.
Working with Bookmarks.
More on Projects.
Importing and Exporting Resources.
Running Multiple Eclipse Windows.
Customizing Your JRE.
Using Other Computer Programs with Eclipse.
More on Preferences.
Chapter Summary.3. Using Java Development Tools.
Overview of the JDT User Interface.
Writing Java Code.
Navigating Java Errors and Warnings.
Fixing Java Errors with Quick Fix.
Using Code Templates.
Writing Java for Nondefault JREs.
Running Java Code.
Using the Run Action.
Managing Launch Configurations.
Evaluating Expressions in Scrapbook Pages.
Working with Java Elements.
More on Java Projects.
Creating Java Projects.
Creating Classes and Interfaces.
Importing Java Elements.
Local History for Java Elements.
Tuning the Performance of JDT.
More on JDT Views and Perspectives.
Filtering View Contents.
Package Explorer View.
Java Type Hierarchy Perspective.
Java Browsing Perspective.
Chapter Summary.4. Debugging Java.
Setting a Breakpoint.
Starting a Debugging Session.
Controlling Program Execution.
Examining an Executing Program.
Additional Debugging Capabilities.
Changing Variable and Field Values.
Debugging with the Java Editor.
Manipulating the Programs You're Debugging.
More on Breakpoints.
Java Exception Breakpoints.
Program Output in the Console View.
Debug Launch Configurations.
Associating a Source with Your Programs.
Hot Code Replace.
Chapter Summary.5. Teaming Up with Eclipse.
Eclipse Support for CVS.
General Team Support by Eclipse.
Common Principles of Eclipse Team Support.
Configuring Team Support.
An Overview of CVS for the Novice.
Some Key CVS Design Principles.
Revisions: Nothing Ever Goes Away.
Updating: Keeping Up with the Team.
Committing: Your Turn to Share.
Versioning: Capturing the Moment.
Branching and Merging: Support for Parallel Development.
What Happens to Revision Numbers During Branching and Merging.
Managing Binary Files Using CVS.
The CVS User Interface in Eclipse.
CVS Repository Exploring Perspective: Your Repository Home Page.
The CVS Repositories View.
The CVS Resource History View.
The CVS Console View.
How CVS Managed Projects Appear in Your Workspace.
CVS Actions Available from the Team Menu.
The Very Important CVS Synchronize View.
Handling Concurrent Updates to the Same File.
Special Situations and How to Handle Them.
Renaming, Moving, and Deleting Project Resources.
Backing Out a Change: Using Replace and Compare.
Setting up Branches for Maintenance and New Release Development.
Patches: Sharing Changes Quickly and Easily.
Project Sets: Getting That New Workspace Up to Speed.
Disconnecting or Reassigning a CVS Project.
References.6. Eclipse Configuration Management.
Structure of an Eclipse Installation.
Eclipse Directory Content.
The Role of Plug-ins.
The Role of Features.
Identifying Features in the Run-Time Platform.
Update Manager-An Introduction.
The Configuration, Install Sites, and Update Sites.
Viewing Your Configuration.
Install Configuration View.
Feature Updates View.
Managing Configuration Processing.
Eclipse Startup-the First Time.
Beyond the First Time-Subsequent Platform Launches.
Establishing a Default Configuration.
Preloading Features on a Default Configuration.
Sharing the Platform with Others-Multi-User Install.
II. EXTENDING ECLIPSE.7. Overview of the Eclipse Architecture.
The Eclipse Platform.
User Interface Frameworks.
Standard Widget Toolkit.
Resources and Workspace API.
References.8. Getting Started: Plug-in Development.
Getting Started with Plug-ins.
Distributing Your Eclipse-Based Tool.
Getting Started with Extensions and Extension Points.
Basic Steps of Implementing a Plug-in.
Declaring Your Plug-in Manifest.
Defining Your Plug-in Class 216Installing Your Plug-in.
Using the Plug-in Development Environment.
PDE Views and Editors.
Managing the Run-Time and Development Environment.
Creating and Running a Plug-in.
Developing Eclipse with Eclipse: Standalone Versus Distributed Self-Hosting.
References.9. Action Contributions: The Integration Fast Track.
Action Contribution Extension Points.
The Fundamentals of Action Contributions.
The Contribution Action API.
Specifying Contributions in the Plug-in Manifest File.
Specifying Actions in Menus and Toolbars.
Using Filters to Refine Where Your Actions Appear.
The Class Selection Filter.
Creating Elaborate Filters Using Action Expressions.
Contributing to the Workbench Menu Bar and Toolbar.
Defining Menu and Toolbar Actions Independent of Perspectives.
Contributing to the View's Menu and Toolbar.
Contributing to an Editor's Menu and Toolbar.
Contributing Context Menus to Views and Editors.
Contributing a Context Menu to a View.
Contributing a Context Menu to an Editor.
Contributing a Context Menu to an Object in a View.
References.10. The Standard Widget Toolkit: A Lean, Mean Widget Machine.
The Basic Structure of an SWT Application.
Common SWT Widgets.
Refining a Widget's Appearance Using Style Bits.
Responding to Widget Events.
How to Arrange SWT Widgets Using Layout Managers.
Widgets Have Special Disposal Requirements.
Using Threads to Separate UI and non-UI Activities.
An Overview of SWT Packages.
References.11. Dialogs and Wizards.
Dialogs-You Can Find Them Everywhere.
Point of Reference-The UI Framework.
Workbench Extension Points for Dialogs and Wizards.
Common Reusable Dialogs.
Extending the Preferences Dialog to Add Your Own Tool Options.
Defining a Preference Page Extension.
Implementing a Preference Page.
Defining the Preference Page User Interface.
Preference Management in a Plug-in.
Establishing Default Preference Setting Values.
Adding Preference Value Logic to Preference Page.
Reacting to Preference Setting Changes.
Building a Field Editor Preference Page.
Using Property Pages to Remember Something Special About a Resource.
Defining a Property Page Extension.
Implementing a Property Page.
Defining the Property Page User Interface.
Adding Resource Property Access Logic.
Resource Generic Memories-Using the Inherited Preferences Implementation.
Implementing Your Own Properties Dialog.
Using Wizards to Extend Workbench Resource Creation and Import/Export Support.
Adding Wizards to the Workbench User Interface by Extension.
Implementing a Wizard.
Implementing a Wizard Page.
Customizing the Wizard.
Controlling Wizard Page Progression.
Reusable Specialized Wizard Pages.
Directly Opening a Wizard Dialog.
Using a Dialog Setting.
View Behavior and Architecture.
Basic Implementation Steps.
Designing the Look of the View.
Declaring the View Extension.
Creating the View Class.
Creating the Content Provider.
Creating the Label Provider.
Associating the Viewer and the Model.
Synchronizing the Model and View.
Handling User Selections.
Filtering the View.
Sorting the View.
Adding View Actions.
Supporting Global Actions in Views.
Adding Label Decorations on Objects in a View.
Interacting with Other Views.
Editor Behavior and Architecture.
Basic Implementation Steps.
Designing the Look of the Editor.
Creating a New Wizard for the Editor Input (Optional).
Declaring the Editor Extension Point.
Creating the Editor Class.
Instantiating the Model Using the Editor Input.
Creating the Content Provider.
Creating the Label Provider.
Handling User Modifications of the Editor Input.
Handling the Saving of the Editor Input.
Associating the Viewer and the Model.
Synchronizing the Model and the Editor.
Handling User Selections.
Adding Editor Actions.
Linking an Editor and the Outline View.
Creating a Perspective.
Using the perspective extensions Extension Point.
References.15. Workspace Resource Programming.
Resource Model and File System Interaction.
Workspace and Workspace Root-Entry Point for Services and Resources.
Workspace Resource Handles-Understanding What You Get When You Ask.
Working with Projects.
Working with Resources.
Working with Paths.
Working with Folders and Files.
Processing the Resource Tree.
Processing Workspace Change Events.
Tracking Changes Using the Workspace API.
Adding Resource Change Listeners.
Visiting the Resource Delta.
Resource Delta Content.
Resource Modification Event Management.
Using Workspace Save Events to Save Critical Data.
Save Events-What and When.
Save Participant API.
References.16. Managing Resources with Natures and Builders.
Customizing Project Processing.
Extending the Workspace Resource Processing Framework.
Projects and Project Descriptions.
Defining and Implementing Natures.
Creating Natures to Support Project Configuration.
Adding a Nature to a Project.
Managing Nature-Builder Relationships.
Using a Custom Image to Identify Your Project Nature.
Implementing a Custom Builder.
Builder Concepts-The How and When of Build Processing.
Builder Requirements-Why You Should, or Should Not, Create a Builder.
Defining Builders for Incremental Resource Transformation.
References.17. Resource Tagging Using Markers.
Creating Markers for Customized Resource Tagging.
Creating New Marker Types.
Extending Markers with Help and Resolution Support.
References.18. Contributions Revisited.
A Few More Contribution Nuggets.
Chapter Summary.19. Advanced Plug-in Development.
Plug-in Class Loader.
Run-Time Discovery and Delayed Loading.
Fragments as Language Packs.
Fragments as Platform-Specific Content.
References.20. Creating New Extension Points: How Others Can Extend Your Plug-ins.
Overview of the Eclipse Architecture, Revisited.
Relationship Between Extension Points and Extensions.
Plug-in Registry: The Official List of Enabled Plug-ins, Extensions, and Extension Points.
How to Define New Extension Points.
Choosing the Existing Code You Want to Enable Others to Extend or Configure.
Declaring the Existence of the New Extension Point.
Defining an Interface for Expected Behavior.
Processing the Plug-in Registry Entries for Your Extension Points.
Invoking the Appropriate Methods Per the Previously Defined Interface Contract.
How to Enable the Schema-Based New Extension Wizard.
Why Define a Schema?
Plug-in Diagnostics: System and Configuration Information.
Workbench Status Objects: A Status Collector.
Exception Handling: Error Detection.
Error Dialogs: Providing Detailed Status in Error Messages.
Error Dialog Example.
Run-Time Tracing: A Run-Time Diagnostic Tool.
Using Tracing in a Production Environment.
Diagnostics: A Comprehensive Error Log.
Error Logging: Writing to the Workbench Error Log.
Adding Error Logging.
Chapter Summary.22. Developing Features.
All About Features.
Types of Features.
Creating Structure with Features.
Identifying Prerequisites, Included Features, and Plug-ins.
Prerequisite Version-Matching Rules.
Servicing Your Features.
Branding Content in a Feature and Plug-in.
Identifying the Primary Feature.
Product and Feature Branding in the User Interface.
Building on Eclipse.
Creating an Installable Feature.
Building Your Own Product on the Eclipse Platform.
Building Extensions to Other Products.
Delivering Features for Installation Using Update Manager.
Using the PDE for Feature Development and Deployment.
References.23. Providing Help.
Integrating Your Online Documentation.
Creating Help Content as HTML Content.
Declaring the Help Extension.
Creating Table of Contents Files.
Eclipse Online Documentation.
Creating Context-Sensitive Help.
Declaring the Help Context Extension.
Defining the Contents of the Infopop.
Associating the Infopop with the UI Context.
Running Nonintegrated Help.
Customizing Your Help System.
References.24. OLE and ActiveX Interoperability.
COM Support in Eclipse.
In-Place OLE Documents.
In-Place ActiveX Controls.
COM Container Support.
Creating an OleFrame Object.
Creating an OleClientSite Object.
Activating an OLE Object.
Deactivating an OLE Object.
Eclipse OLE Editor Support.
Creating an OleControlSite Object.
Activating the OleControlSite Object.
OLE Automation-Accessing Extended Behavior.
OLE exec Command.
Invocation Without Parameters.
Invocation with Parameters.
Events and Property Listeners.
References.25. Swing Interoperability.
Background on Integration of Swing and SWT.
Launch and Edit Integration.
Modes of Invocation.
Improving the End User Experience.
ABCEditor Example-In-Process Invocation.
Implementation Details-In-Process Invocation.
References.26. Extending the Java Development Tools.
What Is the JDT and What Does It Do?
Accessing Reusable JDT Functionality.
Compiling Java Source Code.
Analyzing Java Source Code.
JDT Abstract Syntax Tree.
Finer-Grain Parsing of Java Source Code.
Manipulating Java Source Code.
Simple Java Element Source Code Manipulations.
More Complex Source Code Manipulations.
Where the JDT Extends Eclipse.
Extending the JDT User Interface.
Contributing View Actions.
Contributing Editor Actions.
Contributing to Java Element Context Menus.
Contributing to Specific View or Editor Context Menus.
Contributing to Global Actions.
Reusing Common JDT Selection Dialogs.
References.27. Building a Custom Text Editor with JFace Text.
Standard Text Editor Functions.
Text Editing and Viewing.
Standard Menus and Toolbar Items.
Standard Marker Representation.
Editor Configuration: Customization Points.
What Is Content Assist?
What Is Syntax Highlighting?
What Is Content Formatting?
Under the Covers of the Text Editor.
AbstractTextEditor Class Relationships.
How to Create a Basic Source Editor.
Phase 1: Creating a Basic Editor.
Phase 2: Adding Content Assist to Your Basic Editor.
Phase 3: Adding Syntax-Based Color Highlighting.
Phase 4: Defining Content Formatting.
III. EXERCISES.28. Exercise 1: Using Eclipse.
Section 1: Your First Eclipse Project.
Section 2: Editors and Views.
Section 3: Working with Resources.
Section 4: Perspectives.
Section 5: Using Multiple Eclipse Windows.
Section 6: Getting Help.29. Exercise 2: Using the Java Development Tools.
Section 1: Hello World.
Section 2: Quick Fix.
Section 3: Code Generation.
Section 4: Refactoring.
Section 5: Launch Configurations.
Section 6: JRE 1.4 Code.30. Exercise 3: Debugging Java.
Section 1: Debugging.
Section 2: Debugging Threads.
Section 3: Remote Debugging.31. Exercise 4: Using CVS with Eclipse.
Creating Your Workspace Project.
Section 1: Getting Started.
Setting Your Team and CVS Preferences.
Defining a CVS Repository Location.
Putting the Project Under CVS Control.
Storing the Project Contents in CVS.
Versioning the Project.
Section 2: Updating, Committing, and Resolving Conflicts.
Modifying the Code in Your Project.
Storing Your Changes in CVS.
Making Additional Changes in Your Project.
Resolving Conflicts with CVS.
Section 3: Branching and Merging.
Branch and Merge Process Using Eclipse.
Updating Your Project and Storing the Changes in a CVS Branch.
Merging Your Project Changes from the Branch Back to CVS HEAD.
Exercise Activity Review.32. Exercise 5: Modifying Your Configuration with Update Manager.
Section 1: Installing New Features.
Section 2: Disabling Features.
Section 3: Pending Changes-Discovering Direct Configuration Modification.
Section 4: Searching for New or Updated Features.33. Exercise 6: Using the Plug-in Development Environment.
Section 1: "Hello, World" in Five Minutes or Less.
Section 2: "Hello, World" with Detailed Step-by-Step Instructions.
Section 3: Testing with the Run-Time Workbench.
Section 4: Debugging with the Run-Time Workbench.
Section 5: Exploring (and Sometimes Correcting) the Eclipse Platform Code.
Section 6: Correcting Common Problems.
Exercise Activity Review.34. Exercise 7: Feature Development and Deployment.
Section 1: Tasks of an Eclipse Feature Developer.
Generating JAR Files for Selected Plug-ins.
Packaging the Function Provided by Your Plug-ins as a Feature.
Adding Product and Feature Branding to the Feature.
Repackaging the Feature.
Extracting an Installable Feature from Workspace and Implementing an Update Site.
Section 2: Tasks of an Eclipse User.
Installing a New Feature as an Extension to an Existing Product.
Adding a Feature to an Existing Product Configuration from an Update Site.
Section 3: Tasks of a Product Developer.
Implementing a Branded Product.
Launching and Reviewing a Branded Product Installation.
Exercise Activity Review.
In 2000, the authors formed the core of a group within IBM called the Jumpstart team. Our team was created to share knowledge of the Eclipse technology throughout IBM and with its business partners, that is, to 'jumpstart' the IBM and partner development community on Eclipse. Part of this effort included the creation of a set of presentations, lecture materials, and accompanying exercises. Over the ensuing months, as the Eclipse technology matured, the presentation and exercises matured as well. As the Eclipse community grew to include various companies and academic institutions, requests for this information grew as well. After every class taught, we revised and improved the materials. When our schedules could not keep pace with the demand, we adapted the materials and made them available to use in a self-study mode. This was the genesis of this book. You can think of each chapter in the book as a lesson in class. The exercises and solutions reinforce the concepts of the chapter and provide you with practice using or extending an aspect of Eclipse.
Our goals in bringing you this book are to:
1. Provide information for those new to Eclipse.
2. Explore the capabilities of Eclipse
The book will cover both using Eclipse as your development environment and extending Eclipse. The chapters on using Eclipse start with its use as a general development environment and then progress on to developing and debugging Java and more advanced usage topics, for example using Eclipse in a team environment. In the chapters in extending Eclipse in Part II, we cover the most common classes for each Eclipse framework. References to design patterns, where applicable, illustrate the architectural relationships among the classes. The intent is not to replace the Javadoc that is included with Eclipse, but to compliment the documentation by focusing on how to bring a set of classes together to complete a task.
3. Provide exercises and working examples that are simple and focused on the chapter topic.
4. Provide reference material for those experienced in using Eclipse.
5. Promote the Eclipse community
Though the term "Eclipse" conveys the image of a solar eclipse causing darkness, the intent of this book is to shed light, add clarity, and focus on a powerful new platform. Whether you are new to Eclipse or one of the early adopters, we welcome you to the Eclipse community.
The audience for this book includes Java programmers who plan to use Eclipse as their integrated development environment (IDE), those who will use Eclipse-based offerings, advanced users who want to customize Eclipse further, and tool providers that seek to develop tools that will integrate with Eclipse and other Eclipse-based offerings. This book assumes that you are familiar with the Java programming language. While it describes how to use the Java development tools, it does not teach the syntax and semantics of the Java programming language.
Part I of the book applies to those using Eclipse as their development environment. The book begins by covering the basic navigation and terminology of Eclipse. You will learn about the Java development environment including secrets to becoming a power user. You will learn how to use the flexibility of Eclipse to maximize your productivity and fit your own personal style. Students who are studying the Java programming language may find using Eclipse, instead of simply a command line environment, a much more productive and exciting way to learn the richness and power of the Java programming language. Instructors may discover how using Eclipse in the classroom will accelerate the student's mastery of the language and be a productive tool to use in research.
If you are interested in extending the Eclipse base with additional capabilities or building an offering based on Eclipse, then continue on reading Part II. The chapters describe how to build a plug-in and the various Java frameworks provided to make contributing additional function to Eclipse easier and more consistent. It will cover how to add menu choices, toolbar buttons, views, editors, dialogs, and online documentation to Eclipse.
Learning in a programming environment without actually writing code is difficult. Part III contains a series of detailed exercises to reinforce the concepts presented in the chapters. Part III depends on the files included on the CD-ROM. Template files that provide scaffolding code accompany some of the exercises. During the completion of the exercises, you will fill in the missing code. The template files include Eclipse Scrapbook Page files with the file extension of .jpage. These files can be used to copy and paste into the .java files to complete the exercises without doing a lot of typing. In addition, the CD-ROM contains solutions to all of the exercises plus many code samples augmenting the material in the chapters. The samples do not depend on one another, so you can study them in any order.
There are many Eclipse-based tools available today and more under development, including ones for C++, Web services, J2EE programming, and UML modeling. This book focuses on the use of Eclipse by the Java developer. However, the fundamentals of Eclipse covered in the first few chapters can be used across all types of tools.
This book includes a CD-ROM with the following:
To complete the exercises, you must install Eclipse SDK version 2.0. The Eclipse SDK requires that you install a Java Development Kit (JDK) version 1.3 or higher. You may download a JDK from http://www.ibm.com/java/jdk or http://java.sun.com. The files on the CD-ROM are designed for Windows2000 and WindowsXP. Because the examples are written in the Java programming language, you can use them on other operating systems as well, as long as the code or instructions do not depend on Windows specific function. See the file readme.html on the CD-ROM for more information.
Download Foreword related to this title.
Download the Index
file related to this title.
Updated: 10, September 2003
Send feedback on the book to: JDG2E@yahoogroups.com
The following is a listing of errors found on the CD_ROM plus additional, new content.
The SQL editor contained on the CD-ROM in the project,
missing the properties file. When running the solution without the properties file, the following error messages appear.
The corresponding console message is:
Unable to create editor contributor: com.ibm.lab.soln.sqleditor.editor
was unable to instantiate class
sqltexteditorproperties.zip , unzip the file and copy
into the package;
The key binding API changed considerably from 2.0 to 2.1. Retargetable actions
require an explicit binding of your editor's action to the platform
action. The platform changes broke two functions in the original version of the SQL Editor. The content assist key Ctl+Space is not enabled. In
addition the global editor actions; Copy, Cut, Paste, Undo, Redo, and Revert are disabled. Note that not all the following fixes are backward
action created in the
method must set the action definition id of the action.
method is used for this purpose.
See the pertinent code in the
created in TextEditorActionContributor
extensions must set the action definition id.
The setActionDefinitionId() method of RetargetTextEditorAction is used for this purpose. See the affected code in the
constructor of the SQLEditorContributor class.
implementing custom actions in a JFace text editor, enabling the global editor
actions; Copy, Cut, Paste, Undo, Redo, and
Revert requires calling the createActions() method in the super class, AbstractTextEditor. See the first line of code in the
createActions() method in the
unzip the file and from Eclipse perform
File > Import… External Plug-ins and Fragments.