You are previewing Eclipse Cookbook.
O'Reilly logo
Eclipse Cookbook

Book Description

You've probably heard the buzz about Eclipse, the powerful open source platform that gives Java developers a new way to approach development projects. It's like a shiny new car--no longer content to just admire Eclipse, you're now itching to get in and drive. Eclipse is to Java developers what Visual Studio is to .NET developers--it's an integrated development environment (IDE) that combines a code editor, compiler, debugger, text editor, graphical user interface (GUI) builder, and other components into a single, user-friendly application. It provides a solid foundation that enables Java developers to construct and run integrated software-development tools for web development, application design, modeling, performance, testing, and much more. As with any extensive programming tool, however, there's a lot to learn. And there s no better guy than well-known Java expert Steve Holzner to teach you. An award-winning and best-selling author who has been writing about Java topics since the language first appeared, Holzner delivers just the kind of targeted, practical, everyday knowledge you need to hone your mastery of Eclipse. Perfect as a companion to an Eclipse programming tutorial (such as Holzner's own Eclipse, O'Reilly, April 2004) or an ideal stand-alone for all those developers who either don't want or don't need the tutorial approach, the Eclipse Cookbook contains task-oriented recipes for more than 800 situations you may encounter while using this new Java platform--from deploying a web application automatically to reverse engineering compiled code, from re-naming all references to a class across multiple packages to initializing the SWT JNI libraries. Each recipe in the ever-popular and utterly practical problem-solution-discussion format for O'Reilly cookbooks contains a clear and thorough description of the problem, a brief but complete discussion of a solution, and in-action examples illustrating that solution. The Eclipse Cookbook will satiate Java programmers at all levels who are ready to go beyond tutorials--far beyond writing plug-ins and extensions--and actually use the powerful and convenient Eclipse day to day.

Table of Contents

  1. Eclipse Cookbook
    1. Preface
      1. What’s Inside
      2. Conventions Used in This Book
      3. What You’ll Need
      4. Using Code Examples
      5. We’d Like to Hear from You
    2. 1. Basic Skills
      1. Introduction
      2. 1.1. Getting Eclipse
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. 1.2. Installing and Running Eclipse
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. 1.3. Understanding Your Workspace
        1. Problem
        2. Solution
        3. Discussion
          1. The Eclipse platform kernel
          2. The workbench component
          3. The workspace component
          4. The team component
          5. The help component
          6. Plug-ins
      5. 1.4. Running Multiple Eclipse Windows
        1. Problem
        2. Solution
        3. Discussion
          1. Multiple Eclipse windows, same workspace
          2. Multiple Eclipse windows, multiple workspaces
          3. Multiple Eclipse installations
          4. Runtime workbench
      6. 1.5. Creating a Java Project
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. 1.6. Managing Perspectives, Views, and Editors
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. 1.7. Mastering the Java Perspective
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      9. 1.8. Creating a Java Class
        1. Problem
        2. Solution
        3. Discussion
      10. 1.9. Completing Code Automatically
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. 1.10. Running Your Code
        1. Problem
        2. Solution
        3. Discussion
      12. 1.11. Running Code Snippets
        1. Problem
        2. Solution
        3. Discussion
      13. 1.12. Fixing Syntax Errors Automatically
        1. Problem
        2. Solution
        3. Discussion
      14. 1.13. Keeping Your Workspace Clear
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      15. 1.14. Recovering from Total Disaster
        1. Problem
        2. Solution
        3. Discussion
    3. 2. Using Eclipse
      1. Introduction
      2. 2.1. Showing/Hiding Views
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. 2.2. Moving a View or Toolbar
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. 2.3. Accessing Any Project File
        1. Problem
        2. Solution
        3. Discussion
      5. 2.4. Tiling Editors
        1. Problem
        2. Solution
        3. Discussion
      6. 2.5. Maximizing Views and Editors
        1. Problem
        2. Solution
        3. Discussion
      7. 2.6. Going Back to the Previous Editor
        1. Problem
        2. Solution
        3. Discussion
      8. 2.7. Going Back to the Previous Edit Location
        1. Problem
        2. Solution
        3. Discussion
      9. 2.8. Linking Views to Editors
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. 2.9. Reordering View and Editor Tabs
        1. Problem
        2. Solution
        3. Discussion
      11. 2.10. Navigating from an Editor to a View
        1. Problem
        2. Solution
        3. Discussion
      12. 2.11. Creating a Key Binding
        1. Problem
        2. Solution
        3. Discussion
      13. 2.12. Displaying More Resource Information with Icons
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      14. 2.13. Using a Different Workspace
        1. Problem
        2. Solution
        3. Discussion
      15. 2.14. Creating a Task
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      16. 2.15. Creating a Bookmark
        1. Problem
        2. Solution
        3. Discussion
      17. 2.16. Creating a Fast View
        1. Problem
        2. Solution
        3. Discussion
      18. 2.17. Customizing Help
        1. Problem
        2. Solution
        3. Discussion
      19. 2.18. Restoring Deleted Resources
        1. Problem
        2. Solution
        3. Discussion
      20. 2.19. Customizing a Perspective
        1. Problem
        2. Solution
        3. See Also
      21. 2.20. Restoring a Perspective
        1. Problem
        2. Solution
        3. Discussion
      22. 2.21. Creating a New Perspective
        1. Problem
        2. Solution
        3. Discussion
    4. 3. Java Development
      1. Introduction
      2. 3.1. Speeding Up the JDT Editor
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
      3. 3.2. Creating a Java Project
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. 3.3. Creating Java Packages
        1. Problem
        2. Solution
        3. Discussion
      5. 3.4. Creating a Java Class
        1. Problem
        2. Solution
        3. Discussion
          1. Creating an anonymous inner class
      6. 3.5. Creating a Java Method
        1. Problem
        2. Solution
        3. Discussion
      7. 3.6. Overriding a Java Method
        1. Problem
        2. Solution
        3. Discussion
      8. 3.7. Getting Method Parameter Hints
        1. Problem
        2. Solution
        3. Discussion
      9. 3.8. Inserting Method Parameter Names
        1. Problem
        2. Solution
        3. Discussion
      10. 3.9. Creating Getter/Setter Methods
        1. Problem
        2. Solution
        3. Discussion
      11. 3.10. Creating Delegate Methods
        1. Problem
        2. Solution
        3. Discussion
      12. 3.11. Surrounding Code with do/for/if/try/while Blocks
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      13. 3.12. Finding the Matching Brace
        1. Problem
        2. Solution
        3. Discussion
      14. 3.13. Automatically Wrapping Strings
        1. Problem
        2. Solution
        3. Discussion
      15. 3.14. Creating a Constructor
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      16. 3.15. Converting Constructors to Factory Methods
        1. Problem
        2. Solution
        3. Discussion
      17. 3.16. Commenting Out a Section of Code
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      18. 3.17. Creating Working Sets
        1. Problem
        2. Solution
        3. Discussion
      19. 3.18. Creating TODO Tasks
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
      20. 3.19. Customizing Code Assist
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
    5. 4. Refactoring, Building, and Launching
      1. Introduction
        1. Eclipse 3.0
      2. 4.1. Renaming Elements
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      3. 4.2. Moving Elements
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. 4.3. Extracting and Implementing Interfaces
        1. Problem
        2. Solution
        3. Discussion
          1. Extracting an interface
          2. Implementing an interface
      5. 4.4. Searching Code
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
      6. 4.5. Comparing Files
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. 4.6. Comparing Files Against Local History
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      8. 4.7. Restoring Elements and Files from Local History
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      9. 4.8. Selecting the Java Runtime for Builds
        1. Problem
        2. Solution
        3. Discussion
          1. Setting the JVM using the -vm switch
        4. See Also
      10. 4.9. Running Your Code
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      11. 4.10. Building Your Code
        1. Problem
        2. Solution
        3. Discussion
          1. Changing the build order
          2. Building only selected projects
      12. 4.11. Using .jar and .class Files
        1. Problem
        2. Solution
        3. Discussion
          1. Creating classpath variables
          2. Using classpath variables
        4. See Also
      13. 4.12. Setting the Launch Configuration
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    6. 5. Testing and Debugging
      1. Introduction
      2. 5.1. Installing JUnit
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. 5.2. Testing an Application with JUnit
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      4. 5.3. Starting a Debugging Session
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      5. 5.4. Setting a Breakpoint
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      6. 5.5. Stepping Through Your Code
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. 5.6. Running Until Encountering a Breakpoint
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      8. 5.7. Running to a Line of Code You Select
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      9. 5.8. Watching Expressions and Variables
        1. Problem
        2. Solution
        3. Discussion
      10. 5.9. Setting a Hit Count for Breakpoints
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. 5.10. Configuring Breakpoint Conditions
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      12. 5.11. Creating Field, Method, and Exception Breakpoints
        1. Problem
        2. Solution
        3. Discussion
          1. Field breakpoints
          2. Method breakpoints
          3. Exception breakpoints
          4. Eclipse 3.0
        4. See Also
      13. 5.12. Evaluating Expressions
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      14. 5.13. Assigning Values to Variables While Debugging
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      15. 5.14. Changing Code on the Fly
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    7. 6. Using Eclipse in Teams
      1. Introduction
      2. 6.1. Getting a CVS Server
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. 6.2. Creating a CVS Repository
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. 6.3. Connecting Eclipse to a CVS Repository
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      5. 6.4. Storing an Eclipse Project in a CVS Repository
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. 6.5. Committing Files to the CVS Repository
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. 6.6. Visually Labeling Files Under Version Control
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. 6.7. Examining the CVS Repository
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      9. 6.8. Checking Projects Out of a CVS Repository
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. 6.9. Updating Your Code from a CVS Repository
        1. Problem
        2. Solution
        3. Discussion
      11. 6.10. Synchronizing Your Code with the CVS Repository
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      12. 6.11. Creating Code Patches
        1. Problem
        2. Solution
        3. Discussion
      13. 6.12. Naming Code Versions
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      14. 6.13. Creating CVS Branches
        1. Problem
        2. Solution
        3. Discussion
    8. 7. Eclipse and Ant
      1. Introduction
      2. 7.1. Connecting Ant to Eclipse
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      3. 7.2. Building an Eclipse Application Using Ant
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      4. 7.3. Catching Ant Build File Syntax Problems
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      5. 7.4. Using a Different Build File
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      6. 7.5. Using Your Own Version of Ant
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      7. 7.6. Setting Types and Global Properties
        1. Problem
        2. Solution
        3. Discussion
      8. 7.7. Setting Ant Editor Options
        1. Problem
        2. Solution
        3. Discussion
      9. 7.8. Setting Ant Arguments
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
      10. 7.9. Using the Ant View
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
      11. 7.10. Using Ant as an External Tool
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    9. 8. SWT: Text, Buttons, Lists, and Nonrectangular Windows
      1. Introduction
      2. 8.1. Working with SWT Widgets
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      3. 8.2. Creating an SWT Application
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. 8.3. Adding the Required SWT JAR Files to the Build Path
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. 8.4. Launching an SWT Application
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. 8.5. Positioning Widgets and Using Layouts
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. 8.6. Creating Button and Text Widgets
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. 8.7. Handling SWT Widget Events
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      9. 8.8. Creating List Widgets
        1. Problem
        2. Solution
        3. Discussion
      10. 8.9. Creating Composite Widgets
        1. Problem
        2. Solution
        3. Discussion
      11. 8.10. Creating Nonrectangular Windows
        1. Problem
        2. Solution
        3. Discussion
      12. 8.11. Multithreading SWT Applications
        1. Problem
        2. Solution
        3. Discussion
    10. 9. SWT: Dialogs, Toolbars, Menus, and More
      1. Introduction
      2. 9.1. Creating Message Boxes
        1. Problem
        2. Solution
        3. Discussion
      3. 9.2. Creating Dialogs
        1. Problem
        2. Solution
        3. Discussion
      4. 9.3. Creating Toolbars
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. 9.4. Embedding Buttons in Toolbars
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. 9.5. Handling Toolbar Events
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. 9.6. Embedding Combo Boxes, Text Widgets, and Menus in Toolbars
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. 9.7. Creating a Menu System
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      9. 9.8. Creating Text Menu Items
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. 9.9. Creating Image Menu Items
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. 9.10. Creating Radio Menu Items
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      12. 9.11. Creating Menu Item Accelerators and Mnemonics
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      13. 9.12. Enabling and Disabling Menu Items
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      14. 9.13. Creating Menu Separators
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      15. 9.14. Creating Tables
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      16. 9.15. Creating Table Columns
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      17. 9.16. Adding Check Marks to Table Items
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      18. 9.17. Enabling and Disabling Table Items
        1. Problem
        2. Solution
        3. Discussion
      19. 9.18. Adding Images to Table Items
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      20. 9.19. Using Swing and AWT Inside SWT
        1. Problem
        2. Solution
        3. Discussion
    11. 10. SWT: Coolbars, Tab Folders, Trees, and Browsers
      1. Introduction
      2. 10.1. Creating SWT Tab Folders
        1. Problem
        2. Solution
        3. Discussion
      3. 10.2. Creating SWT Coolbars
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. 10.3. Adding Items to Coolbars
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. 10.4. Adding Drop-Down Menus to Coolbars
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. 10.5. Creating SWT Trees
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. 10.6. Handling Tree Events
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. 10.7. Adding Checkboxes to Tree Items
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      9. 10.8. Adding Images to Tree Items
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. 10.9. Creating SWT Browser Widgets
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
    12. 11. JSP, Servlets, and Eclipse
      1. Introduction
      2. 11.1. Installing Tomcat
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. 11.2. Starting Tomcat
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. 11.3. Creating JSP Files
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      5. 11.4. Creating a Servlet
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. 11.5. Installing a Servlet in Tomcat
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. 11.6. Creating a Servlet in Place
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. 11.7. Editing web.xml in Place
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      9. 11.8. Avoiding Output Folder Scrubs
        1. Problem
        2. Solution
        3. Discussion
      10. 11.9. Interfacing to JavaBeans
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. 11.10. Using a Tomcat Plug-in
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      12. 11.11. Creating WAR Files
        1. Problem
        2. Solution
        3. Discussion
          1. Creating an application to deploy
          2. Creating a .war file to deploy
          3. Deploying a .war file
        4. See Also
    13. 12. Creating Plug-ins: Extension Points, Actions, and Menus
      1. Introduction
      2. 12.1. Installing a Plug-in
        1. Problem
        2. Solution
        3. Discussion
      3. 12.2. Creating plugin.xml
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. 12.3. Creating a Menu-Based Plug-in Using Wizards
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
        4. See Also
      5. 12.4. Testing Plug-ins with the Run-time Workbench
        1. Problem
        2. Solution
        3. Discussion
          1. Eclipse 3.0
      6. 12.5. Deploying a Plug-in
        1. Problem
        2. Solution
        3. Discussion
      7. 12.6. Writing a Plug-in from a Skeleton
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. 12.7. Responding to User Actions in a Plug-in
        1. Problem
        2. Solution
        3. Discussion
      9. 12.8. Creating a Plug-in Menu from Scratch
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. 12.9. Creating Actions
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. 12.10. Coding a Plug-in Action
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      12. 12.11. Automatically Adding a Plug-in to a Perspective
        1. Problem
        2. Solution
        3. Discussion
    14. 13. Creating Plug-ins: Wizards, Editors, and Views
      1. Introduction
      2. 13.1. Creating a Plug-in That Supports Wizards and Editors
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. 13.2. Customizing a Wizard
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. 13.3. Customizing an Editor
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. 13.4. Creating a Plug-in That Supports Views
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. 13.5. Adding Items to a View
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. 13.6. Configuring a View’s Actions
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    15. Index
    16. Colophon