NetBeans™ IDE Field Guide: Developing Desktop, Web, Enterprise, and Mobile Applications, Second Edition

Book description

The Only Complete Guide and Reference for NetBeans™ IDE 5.0

The award-winning NetBeans™ IDE eases all aspects of Java application development, incorporating a wide range of powerful features into one well-designed package. NetBeans IDE is consistently first in supporting the latest Java technologies for developing desktop, web, enterprise, and mobile applications.

NetBeans™ IDE Field Guide provides an introduction to the IDE and an extensive range of topics to help you with both everyday and advanced programming tasks, including

  • Taking advantage of the Ant-based project system to create easily deployable projects

  • Developing web applications with the built-in Apache Tomcat web server

  • Constructing, assembling, and verifying large-scale Java EE applications

  • Managing the Sun Java System Application Server through NetBeans IDE

  • Developing mobile applications with the NetBeans Mobility Pack

  • In this expanded second edition, you can also learn how to

  • Build powerful and attractive desktop applications with the Matisse GUI Builder

  • Profile your applications for performance issues

  • Develop modules for NetBeans IDE and rich-client applications based on the NetBeans Platform

  • Chat and share code with other developers using the NetBeans Collaboration Modules



Table of contents

  1. Copyright
  2. Foreword to the First Edition
  3. Foreword to the First Edition
  4. Preface
    1. What is NetBeans IDE?
      1. What Makes NetBeans IDE Special
      2. What Comes with NetBeans IDE
      3. What This Book Will Do for You
    2. How to Use This Book
  5. About the Authors
  6. Acknowledgments for the Second Edition
  7. Acknowledgments for the First Edition
    1. Patrick Keegan
    2. Ludovic Champenois
    3. Gregory Crawley
    4. Charlie Hunt
    5. Christopher Webster
  8. 1. Download, Installation, and First Project
    1. Downloading the IDE
    2. Installing the IDE
    3. Setting a Proxy
    4. First NetBeans IDE Project
  9. 2. NetBeans IDE Fundamentals
    1. Creating a Project
    2. Configuring the Classpath
    3. Creating a Subproject
    4. Creating and Editing Files
    5. Setting Up and Modifying Java Packages
    6. Compiling and Building
    7. Viewing Project Metadata and Build Results
    8. Navigating to the Source of Compilation Errors
    9. Running
    10. Creating and Running Tests
    11. Debugging the Application
    12. Integrating Version Control Commands
    13. Managing IDE Windows
  10. 3. IDE Project Fundamentals
    1. Introduction to IDE Projects
    2. Choosing the Right Project Template
    3. Creating a Project from Scratch
    4. Importing a Project Developed in a Different Environment
    5. Navigating Your Projects
      1. Projects Window
      2. Files Window
      3. Fast Navigation Between the Projects and Files Windows
      4. Physical Structure of IDE Projects
    6. Working with Files Not in the Project
    7. Creating Packages and Files in the Project
      1. File Templates
        1. Java Classes
        2. Java GUI Forms
        3. JavaBeans Objects
        4. JUnit
        5. Web Services
        6. XML
        7. Ant Build Scripts
        8. Web
        9. Other
      2. Starting with a Blank File
    8. Configuring the Project’s Classpath
    9. Changing the Version of the JDK Your Project Is Based On
    10. Changing the Target JDK for a Standard Project
    11. Referencing JDK Documentation (Javadoc) from the Project
    12. Adding Folders and JAR Files to the Classpath
    13. Making External Sources and Javadoc Available in the IDE
    14. Structuring Your Projects
      1. Setting the Main Project
      2. Creating Subprojects
    15. Displaying and Hiding Projects
    16. Compiling a Project
      1. Setting Compiler Options
      2. Compiling Selected Files or Packages
      3. Doing a Fresh Build
      4. Stopping a Build
      5. Changing the Location of Compiled Classes and JAR Files
      6. Compiling Classes into the Same Directories As Your Sources
      7. Investigating Compilation Errors
      8. Saving Build Output
    17. Running a Project in the IDE
      1. Setting or Changing the Project Main Class
      2. Setting Runtime Arguments
      3. Setting Java Virtual Machine Arguments
      4. Setting the Runtime Classpath
    18. Deploying a Java Project Outside of the IDE
      1. Writing Your Own Manifest for Your JAR File
      2. Filtering Contents Packaged into Outputs
    19. Building a Project from Outside of the IDE
      1. Setting up a Headless Build Environment
    20. Customizing the IDE-Generated Build Script
      1. Adding a Target
      2. Adding a Subtarget
      3. Overriding an Existing Target
      4. Inside the Generated Build Scripts
    21. Running a Specific Ant Target from the IDE
    22. Completing Ant Expressions
    23. Making a Menu Item or Shortcut for a Specific Ant Target
      1. Removing a Custom Menu Item or Shortcut
      2. Changing a Custom Menu Item or Shortcut
  11. 4. Versioning Your Projects
    1. Setting up CVS in NetBeans IDE
    2. Checking Out Sources from a CVS Repository
      1. Connecting with SSH
      2. Connecting to a Local CVS Repository
    3. Putting a Project into CVS
      1. Resolving Merge Conflicts in Project Metadata Files
    4. Keeping Track of Changes
      1. Viewing Diffs
    5. Updating Files
    6. Committing Changes
    7. Ignoring Files in CVS Operations
    8. Adding and Removing Files from a Repository
    9. Working with Branches
      1. Creating a Tag
      2. Creating a Branch
      3. Viewing a Working Directory’s Branch
      4. Switching Between Branches
      5. Merging from a Branch
    10. Working with Patches
      1. Creating a Patch
      2. Applying a Patch
    11. Working with Versioning Histories
      1. Viewing the History of a File
      2. Searching for a Commit
      3. Reversing Changes in a File
    12. Working with Other Version Control Systems
  12. 5. Editing and Refactoring Code
    1. Opening the Source Editor
    2. Managing Automatic Insertion of Closing Characters
      1. Finishing a Statement
      2. Splitting a String Between Two Lines
    3. Displaying Line Numbers
    4. Generating Code Snippets without Leaving the Keyboard
    5. Using Code Completion
      1. Code Completion Tricks
      2. Disabling Automatic Appearance of the Java Code Completion Box
      3. Changing Shortcuts for Code Completion
    6. Inserting Snippets from Code Templates
      1. Adding, Changing, and Removing Code Templates
      2. Code Template Syntax
      3. Changing the Expander Shortcut for Code Templates
    7. Using Editor Hints to Generate Missing Code
    8. Matching Other Words in a File
    9. Generating Methods to Implement and Override
    10. Generating JavaBeans Component Code
    11. Creating and Using Macros
    12. Creating and Customizing File Templates
    13. Handling Imports
    14. Displaying Javadoc Documentation While Editing
    15. Formatting Code
      1. Indenting Blocks of Code Manually
      2. Changing Formatting Rules
      3. Changing Fonts and Colors
    16. Text Selection Shortcuts
    17. Navigating within the Current Java File
      1. Viewing and Navigating Members of a Class
      2. Moving the Insertion Point and Scrolling the Window
      3. Bookmarking Lines of Code
      4. Hiding Sections of Code
    18. Navigating from the Source Editor
      1. Switching Between Open Files
      2. Jumping to Related Code and Documentation
      3. Jumping Between Areas Where You Have Been Working
      4. Jumping from the Source Editor to a File’s Node
    19. Searching and Replacing
      1. Finding Occurrences of the Currently Selected Class, Method, or Field Name
      2. Renaming All Occurrences of the Currently Selected Class, Method, or Field Name
      3. Searching and Replacing Combinations of Characters in a File
      4. Other File Searches
    20. Deleting Code Safely
    21. Changing a Method’s Signature
    22. Encapsulating a Field
    23. Moving a Class to a Different Package
    24. Moving Class Members to Other Classes
      1. Moving Code to a Superclass
      2. Moving Code to Subclasses
    25. Creating a Method from Existing Statements
    26. Creating an Interface from Existing Methods
    27. Extracting a Superclass to Consolidate Common Methods
    28. Changing References to Use a Supertype
    29. Unnesting Classes
      1. Moving an Inner Class up One Level
      2. Converting an Anonymous Inner Class to a Named Inner Class
    30. Tracking Notes to Yourself in Your Code
      1. Adding, Removing, and Changing Task-List Tags
      2. Displaying Tasks by Priority
      3. Filtering Task-List Entries
    31. Comparing Differences Between Two Files
    32. Splitting the Source Editor
    33. Maximizing Space for the Source Editor
    34. Changing Source Editor Keyboard Shortcuts
  13. 6. Building Java Graphical User Interfaces
    1. Using Different Layout Managers
    2. Placing and Aligning a Component in a Form
    3. Setting Component Size and Resizability
    4. Setting Component Alignment
    5. Specifying Component Behavior and Appearance
    6. Generating Event Listening and Handling Methods
    7. Customizing Generated Code
    8. Previewing a Form
    9. Using Custom Beans in the Form Editor
      1. Associating an Icon with a Component
    10. Deploying GUI Applications Developed with Matisse
  14. 7. Debugging Java Applications
    1. Starting a Debugging Session
    2. Attaching the Debugger to a Running Application
    3. Starting the Debugger Outside of the Project’s Main Class
    4. Stepping through Code
      1. Executing Code Line by Line
      2. Executing a Method without Stepping into It
      3. Resuming Execution through the End of a Method
      4. Continuing to the Next Breakpoint
      5. Continuing to the Cursor Position
      6. Stepping into the JDK and Other Libraries
      7. Limiting the Classes That You Can Step into for a Library
    5. Setting Breakpoints
      1. Setting a Line Breakpoint
      2. Setting a Breakpoint on a Class Call
      3. Setting a Breakpoint on a Method or Constructor Call
      4. Setting a Breakpoint on an Exception
      5. Setting a Breakpoint on a Field or Local Variable
      6. Setting a Breakpoint on the Start or Death of a Thread
    6. Managing Breakpoints
      1. Grouping Related Breakpoints
      2. Enabling and Disabling Breakpoints
      3. Deleting a Breakpoint
    7. Customizing Breakpoint Behavior
      1. Logging Breakpoints without Suspending Execution
      2. Customizing Console Messages When Breakpoints Are Hit
      3. Making Breakpoints Conditional
    8. Monitoring Variables and Expressions
      1. Setting a Watch on a Variable, Field, or Other Expression
      2. Monitoring the Object Assigned to a Variable
      3. Displaying the Value of a Class’s toString () Method
      4. Changing Values of Variables or Expressions
      5. Displaying Variables from Previous Method Calls
    9. Backing up from a Method to Its Call
    10. Monitoring and Controlling Execution of Threads
      1. Switching the Currently Monitored Thread
      2. Suspending a Single Thread
      3. Isolating Debugging to a Single Thread
    11. Fixing Code During a Debugging Session
    12. Viewing Multiple Debugger Windows Simultaneously
  15. 8. Developing Web Applications
    1. Representation of Web Applications in the IDE
      1. Project View of Web Applications
      2. File View of Web Applications
    2. Adding Files and Libraries to Your Web Application
      1. Creating Web Pages and Other Public Files
      2. Creating Classes, Servlets, and Other Private Files
      3. Adding External Resources to Your Project
      4. Adding Tags and Tag Libraries
    3. Editing and Refactoring Web Application Files
      1. Completing Tags
      2. Using Code Templates for JSP Files
      3. Editing the Deployment Descriptor Manually
      4. Refactoring Web Components
    4. Deploying a Web Application
      1. Customizing Contents of the WAR File
      2. Undeploying a Web Application
      3. Redeploying a Web Application
      4. Creating a WAR File
      5. Deploying to a Different Tomcat Server
    5. Testing and Debugging Your Web Application
      1. Checking for JSP Errors
      2. Viewing a JSP File’s Servlet
      3. Viewing a File in a Web Browser
      4. Passing Request Parameters to a Web Application
      5. Debugging JSP and Tag Files
    6. Creating and Deploying Applets
      1. Creating an Applet
      2. Running and Debugging an Applet in the Applet Viewer
      3. Running an Applet in a Web Browser
      4. Packaging an Applet into a JAR File
      5. Packaging an Applet into a WAR File
      6. Setting Applet Permissions
    7. Changing the IDE’s Default Web Browser
    8. Monitoring HTTP Transactions
      1. Setting up the HTTP Monitor
      2. Setting up the HTTP Monitor for Servers Started Outside of the IDE
      3. Analyzing the Collected Data
      4. Replaying HTTP Requests
  16. 9. Creating Web Applications on the JSF and Struts Frameworks
    1. JSF Overview
      1. Creating a Web Project with JSF Support
      2. Managed Bean Support
      3. JSF Configuration File Support
    2. Struts Overview
      1. Creating a Web Project with Struts Support
      2. Action Support
      3. ActionForm Support
      4. Struts Configuration File Support
  17. 10. Introduction to Java EE Development in NetBeans IDE
    1. Configuring the IDE for Java EE Development
    2. Java EE Server Support
    3. Getting the Most from the Java BluePrints Solutions Catalog
      1. Accessing the Java BluePrints Solutions Catalog
      2. Navigating the Java BluePrints Solutions Catalog
      3. Creating a NetBeans Project from a Java BluePrints Solution
      4. Running a Java BluePrints Solutions Project
  18. 11. Extending Web Applications with Business Logic: Introducing Enterprise Beans
    1. EJB Project Template Wizards
    2. Adding Enterprise Beans, Files, and Libraries to Your EJB Module
    3. Adding Business Logic to an Enterprise Bean
    4. Adding a Simple Business Method
    5. Enterprise Bean Deployment Descriptors
  19. 12. Extending Java EE Applications with Web Services
    1. Consuming Existing Web Services
    2. IDE and Server Proxy Settings
    3. Creating a WSDL File
    4. Implementing a Web Service in a Web Application
      1. Creating a Web Service
      2. Adding an Operation
      3. Compiling the Web Service
      4. Creating Web Services from WSDL
    5. Implementing Web Services within an EJB Module
    6. Testing Web Services
    7. Adding Message Handlers to a Web Service
  20. 13. Developing Full-Scale Java EE Applications
    1. Creating Entity Beans with the Top-Down Approach
      1. Creating an Entity Bean
      2. Selecting a Primary Key Class
      3. Implementing Life-Cycle Methods
      4. Adding Container-Managed Fields
      5. Adding Container-Managed Relationships
      6. Adding Finder Methods
      7. Adding Business Methods
      8. Setting up a Data Source on the Application Server
      9. Mapping a Bean’s Schema to a Persistence Model
    2. Creating Entity Beans with the Bottom-Up Approach
    3. Assembling Enterprise Applications
    4. Importing Existing Enterprise Applications
      1. Importing Java BluePrints Conventions-Compatible Enterprise Application Projects
      2. Importing EJB Modules
    5. Consuming Java Enterprise Resources
      1. Using Enterprise Beans
      2. Using a Database
      3. Sending a JMS Message
    6. Java EE Platform and Security Management
      1. Simple Declarative Security
      2. Registering Users for an Application Server Instance
    7. Understanding the Java EE Application Server Runtime Environment
      1. Server Log
      2. Server Management
      3. JVM Options
      4. JDBC Drivers
      5. Server Properties
      6. Using JavaServer Faces Technology in a Web Application
      7. Working with Ant
    8. Ensuring Java EE Compliance
    9. Refactoring Enterprise Beans
    10. Database Support and Derby Integration
  21. 14. Developing Java ME Mobile Applications
    1. Downloading and Installing the Mobility Pack
    2. Mobility Primer
    3. Configuration vs. Configuration
    4. Setting up Mobility Projects
    5. Creating a Project from Scratch
    6. Importing a Project
    7. Physical Structure of Mobile Projects
    8. Using Mobility File Templates
      1. MIDP Canvas
        1. MIDlet
      2. Localization and Support Class
    9. Configuring the Project’s Classpath
      1. Changing the Project’s Emulator Platform
      2. Installing Nonstandard Emulator Platforms
      3. Adding JAR Files and Folders to the Classpath
    10. Debugging Your Project
    11. Configuring Your Project for Different Devices
      1. Creating a Configuration
      2. Customizing Configurations
    12. Setting the Active Configuration for Your Project
    13. Reusing Project Settings and Configurations
      1. Duplicating Project Settings
      2. Using Project Configuration Templates
    14. Structuring Project Dependencies
      1. Using Dependencies with Configurations
    15. Managing the Distribution JAR File Content
    16. Handling Project Resources for Different Configurations
      1. Using Different Resource Locations
      2. Using Configuration-Specific Code Blocks and the Filtering Panel
    17. Writing Code Specific to a List of Configurations
      1. Duplicating a Code Block
      2. How to Interpret Code Block Visualization
    18. Using the Preprocessor
      1. General
      2. Directives
      3. Variables
      4. Operators
        1. ! (the “not” Operator)
        2. Comparison Operators
        3. Boolean Operators
      5. Expressions
      6. Preprocessor Coding Tips—Compilation Based on Device Platform Versioning
    19. Using Configuration Abilities
    20. Creating and Associating an Ability with a Configuration
    21. Localizing Applications
    22. Using the MIDP Visual Designer
      1. Creating a New Visual Design
      2. Adding Objects to the Component Palette
      3. Building a Small Application with the Visual Designer
    23. Understanding the Flow Designer
      1. Component Palette
      2. Special Components
        1. Splash Screen
        2. Table
        3. Wait Screen
        4. Inspector
        5. Property Sheet
      3. Flow Designer
      4. Toolbar
    24. Understanding the Screen Designer
      1. Device Screen
      2. Assigned Commands
        1. Toolbar
    25. Deploying Your Application Automatically
      1. File Copy
      2. FTP
      3. SCP
      4. WebDAV
      5. Deployment to Sony-Ericsson Devices
    26. Incrementing the Application’s MIDlet-Version Automatically
    27. Using Ant in Mobility Projects
      1. Mobility Ant Library
    28. Using Headless Builds
      1. Computers with NetBeans IDE
      2. Computers without NetBeans IDE
    29. Using the Wireless Connection Tools
      1. Creating Applications that Consume WS-I Compliant Web Services
      2. Creating Applications Using the Web Service Proxy
    30. Finding More Information
  22. 15. Profiling Java Applications
    1. Supported Platforms
    2. Downloading and Installing the NetBeans Profiler
    3. Starting a Profiling Session
    4. The Profiler Control Panel
      1. Controls
      2. Status
      3. Profiling Results
      4. Saved Snapshots
      5. View
      6. Basic Telemetry
    5. Monitoring an Application
    6. Analyzing Performance
      1. Viewing Live Results
      2. Taking a Snapshot of Results
    7. Analyzing Code Fragment Performance
    8. Analyzing Memory Usage
      1. Viewing Live Results
      2. Taking a Snapshot of Results
    9. Attaching the Profiler to a JVM
  23. 16. Integrating Existing Ant Scripts with the IDE
    1. Creating a Free-Form Project
    2. Mapping a Target to an IDE Command
    3. Setting up the Debug Project Command for a General Java Application
      1. Mapping the Project’s Sources to Its Outputs
      2. Creating the Debug Target
    4. Setting up the Debug Project Command for a Web Application
    5. Setting up Commands for Selected Files
    6. Setting up the Compile File Command
      1. Generating a Skeleton Target for Compile File
      2. Handling Properties in the project.xml File
    7. Setting up the Run File Command
      1. Creating the run-selected-file Target
      2. Mapping the run-selected-file Target to the IDE Command
    8. Setting up the Debug File Command
      1. Creating the debug-selected-file Target
      2. Mapping the debug-selected-file Target to the IDE Command
    9. Setting up the Debugger’s Apply Code Changes Command
      1. Creating the debug-fix Target
      2. Mapping the debug-fix Target to the IDE Command
    10. Setting up the Profile Project Command for a General Java Application
    11. Changing the Target JDK for a Free-Form Project
    12. Making a Custom Menu Item for a Target
    13. Debugging Ant Scripts
  24. 17. Developing NetBeans Plug-in Modules
    1. Plug-in Modules
    2. Rich-Client Applications
    3. Extending NetBeans IDE with Plug-in Modules
    4. Setting up a Plug-in Module
      1. Creating a Module Project
      2. Creating a Module Suite Project
      3. Creating a Library Wrapper Module Project
    5. Using the NetBeans APIs
      1. Adding a Menu Item and a Toolbar Button to the IDE
      2. Creating an Editor for a New File Type
      3. Adding a Component to the Main Window
      4. Finding the NetBeans APIs That You Need
    6. Registering the Plug-in Module
    7. Adding a License to a Plug-in Module
    8. Building and Trying Out a Plug-in Module
    9. Packaging and Distributing a Plug-in Module
    10. Packaging and Distributing a Rich-Client Application
    11. Finding Additional Information
      1. Basic Information
      2. Tutorials and FAQs
      3. Contributing
      4. Mailing Lists
  25. 18. Using NetBeans Developer Collaboration Tools
    1. Getting the NetBeans Developer Collaboration Tools
    2. Configuring NetBeans IDE for Developer Collaboration
    3. Creating a Collaboration Account
    4. Managing Collaboration Accounts
      1. Adding Additional Collaboration Accounts
      2. Setting a Default Collaboration Account
      3. Modifying a Collaboration Account
      4. Removing a Collaboration Account
    5. Logging into a Collaboration Server
    6. Collaborating and Interacting with Developers
      1. Contacts and Contact Groups
      2. Conversation Groups
      3. Starting and Joining Conversations
      4. Interacting with other Developers
      5. Sharing IDE Projects
  26. A. Importing an Eclipse Project into NetBeans IDE
    1. Getting the Eclipse Project Importer
    2. Choosing Between Importing with and Importing without Project Dependencies
    3. Importing an Eclipse Project and Preserving Project Dependencies
    4. Importing an Eclipse Project and Ignoring Project Dependencies
    5. Handling Eclipse Project Discrepancies
    6. Handling Eclipse Project Reference Problems
  27. B. Importing a JBuilder Project into NetBeans IDE
    1. Getting the JBuilder Project Importer
    2. Importing a JBuilder 2005 Project
    3. Project Import Warnings
    4. Running the Imported Project

Product information

  • Title: NetBeans™ IDE Field Guide: Developing Desktop, Web, Enterprise, and Mobile Applications, Second Edition
  • Author(s): Patrick Keegan, Ludovic Champenois, Gregory Crawley, Charlie Hunt, Christopher Webster, John Jullion-Ceccarelli, Jiri Prazak, Martin Ryzl, Gregg Sporar, Geertjan Wielenga
  • Release date: May 2006
  • Publisher(s): Pearson
  • ISBN: 0132395525