Tải bản đầy đủ (.pdf) (64 trang)

NetBeans the Definitive User Guide phần 5 pps

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (8.78 MB, 64 trang )

Extending NetBeans
by Tim Boudreau
by Jesse Glick
Copyright © 2001, 2002 O’Reilly & Associates, Inc.
Warning
This is a DRAFT IN PROGRESS and should not be distributed freely! Except with special permission, only O’Reilly employees, authors,
and reviewers should be reading this manuscript at this stage.

Table of Contents
Foreword—byJamesGosling
1.Introduction
Who Should Read this Book? 249
What’sDifferent aboutNetBeans? 250
The Core and theOpen APIs 250
TheLicense 251
Open-Source 252
Thenetbeans.org WebSite 252
NetBeansfor BeanCounters 254
Getting andInstalling the Open APIs Support Module 255
LifeisChange 256
Source code for the examples 256
2.History ofNetBeans
HumbleBeginnings 257
FirstSuccesses, FirstCosts 258
SunMeetsNetBeans 259
Open-Source,Fire-DrillStyle 260
NetBeansToday 260
3. Understanding the NetBeans APIs
DesignPhilosophyofNetBeans 261
Abstracting the Abstractions—the Open APIs 262
Modularity 262


Hierarchy,Files andNodes 263
Everythingis aFile—Virtually 263
Mapping Files to Java Objects 264
TheSystemFilesystem 265
ModuleLayers 265
Layers in the System Filesystem 266
Exploringthe SystemFilesystem 267
Data Objects—Wrappers for Persistent Data 270
NetBeansandJavaBeans 270
Nodes—theApplication asHierarchy 270
Presenting Nodes to the User—Explorer 271
User-LevelCustomization 273
Nodes inAction—Customizing the IDE without Writing Code 275
Modules—Overview 278
HowModules AddFunctionality 278
How Modules Install VirtualFilesystem Layers 279
WhatModules CanDo 279
DisablingModules 280
An Illustration—NetBeans with No Modules at All 280
Interacting with the IDE through Internal Execution 281
Setting the Status Bar Text 282
Settingthe CurrentWorkspace 283
4.The OpenAPIs
The IDE’s Architecture andthe APIs 284
APIs versus Core versus Modules 285
Service Provider Interfaces andClient APIs 286
Overview of the APIs and Their Purposes 286
Modules 287
Lookup and the Services API 294
Nodes 296

Datasystems 299
Explorer 299
Actions 304
Options 305
Compiler 305
Editor 306
WindowingSystem 307
Cookies 309
Execution 310
JavaHierarchy 310
Filesystems 311
Modules, JARs, and Class Loaders 312
Threading, Deadlocks, and How to Avoid Them 317
5. Developing Modules—the NewModule Wizard
TheHelloWorldModule 319
Creating aModule Using the New Module Wizard 319
TheSourceFiles 320
6. Internals of theRunning IDE
TheActivatedNode(s) 323
Cookies 324
A Peek under the Hood—Examining the Activated Nodes with the CurrentNodeViewer 325
Touring NetBeans with theBean Browser 325
Data Objects, Nodes and Cookies 327
FilesystemsandtheRepository 327
Services 328
Lookup 329
Options 330
UIComponents 331
TopComponents,Modes andWorkspaces 331
Actions 336

Presenters 337
CustomPropertyEditors 337
Localization 337
Wizards 338
Jumping-offPlaces 338
Special Folders in theSystem Filesystem 339
7. Creating the QuickPanel Module
Abstractions Covered in this Chapter 342
Creating the Project Files Drop-Down 343
FilterNode—Filtering WhichChildren of a Node are Displayed 347
Creatingthe MethodsDrop-Down 349
Improvingthe MethodsDrop-Down 350
CreatingtheModule 353
Creating a Container GUI Component 354
CreatingtheShowQuickPanelAction 354
Creating the XML Filesystem Layer 355
Creating and Populating theModule JAR 356
Building and Testing the Module 356
ALittleHomework 357
8.A Mail-BasedFilesystem
Building aMail Reader in the NetBeans Paradigm 358
Implementing MailFileSystem Using AbstractFileSystemand JavaMail 359
Creating a New AbstractFileSystem Implementation 359
MailFilesystem:AbstractFileSystem.Info 360
MailFilesystem:AbstractFileSystem.List 361
MailFilesystem:AbstractFileSystem.Change 362
MailFilesystem:AbstractFileSystem.Attr 363
OtherParts ofAbstractFileSystem 363
Creating Folder Objects for Attachments 366
Using FileSystem.Status Annotations to Mark Unread Messages 367

BeanInfo—DisplayingFilesystemProperties 369
Using the Wizard Framework to Set Up Mail Accounts 371
CreatingWizardClasses 371
The IMAP Mail ServerTemplate Wizard 372
9. Creating the User Interface for the Mail Client
Creating a DataLoader for Messages 381
Displaying andEditing Simple Messages and Unnamed Attachments 382
HandlingMultipartMessages 386
Creating aThreaded Mail View Using Filter Nodes 387
Making a Basic Mail View 388
Making aThreaded Mail View as an Alternative 394
Creatinga MailWorkspace 400
10.Score FileSupport
Overview—FunctionalitytobeImplemented 406
Creating the Minicomposer Module—First Things 406
CreatingtheManifest 406
CreatingtheLayer 407
Creating a JAR FileUsing Ant 408
Creating aUniFileLoader and MultiDataObject for *.score Files 408
Creating an Editor Supportfor Scores 411
Creating a Fixed ExecCookie to Play Scores 414
Creatinga SimpleTemplate 417
11. Creatinga Structural View of the Score
Creating a ScoreCookie to Represent a Sequence of Notes 419
Examples ofState-Based Supports in the NetBeans APIs 420
CreatingaScoreSupport 421
Why a Document is Used 421
ImplementationofScoreSupport 422
Lifecycleof theScore 426
AnOpenSupport 426

Creatingan OpenCookieImplementation 427
Showing a GUI View of the ScoreCookie 429
Indicating Parse Errors onthe Node 433
12.CompilingScores
What Does NetBeans Meanby “Compilation”? 437
Creatingthe CompilersThemselves 437
Creating and Using theCompiler Cookie 441
Displaying an Out-of-Date Badge on Score Icons 445
13.ExecutingScores
Execution Service Types—Internal and External 448
Creating the .au Player Executor 448
TheInternalPlayer 449
TheExternalPlayer 451
Registering the Players as Services 454
Creating Player Configuration Support (ExecSupport) 457
Creating a SystemOption for the Default Executor 461
14. Better Score Support in the Explorer
TheClipLengthProperty 467
Clearing the Cache andFiring Changes 469
Adding the Property to the Property Sheet 470
Representing Notes as SubnodesUsing Children.Keys 470
Using Keys to Model Children 471
Being Lazy and Cleaning Up 473
CreatingtheSubnodes 474
Attaching the Children tothe Parent 475
Permitting Subnodes to be Renamed or Deleted 476
DeletionofNotes 476
RenamingofNotes 477
Permitting Subnodes to be Added 479
Making Read/Write Properties on Subnodes 481

ReorderingSubnodes 484
Data Transfer—Cut, Copy, and Paste of Notes and Sequences 489
Overviewof theTransferables 490
CuttingandCopying 491
Pasting 492
Drag&Drop 495
Converting Score # Text, Text # Score, Several Scores # One 495
15. TuningModules for Performance & Memory Footprint
Startup Performance vs. Runtime Performance 501
OperatingPrinciples 501
“Nobody Will Ever UseMy Module” 501
What Does My Module Really Need to Do on Startup? 501
What are the Critical Paths? 502
Techniques 503
LazyInitialization 503
AvoidStaticInitializers 503
Avoid ModuleInstall Classes—Use XMLLayers Instead 504
Partial Loading Considerations—InstanceCookie and InstanceDataObject 505
Use URLs Instead of CDATA Sections in XML Layers 505
Reduce the Number of Classes You Create 505
GUIComponents—Wait foraddNotify() 505
Using the addNotify() and removeNotify() Pattern Where Exposed by Non-GUI Classes 506
Use Weak and Soft References for Objects which May Not be Needed Forever 506
UseWeakListener 508
AvoidExcessive EventFiring 508
AvoidOveruse ofThreads 508
BatchingEvents 509
SwingPerformance 509
16. Producing Modules (Packaging& Distribution)
Versioning 511

Version Numbers and WhatThey Mean 511
SpecifyingDependencies 512
ManagingInter-ModuleDependencies 513
UpgradingUserSettings 516
Settings History and Physical Format 517
UpgradeScenarios forSettings 518
What Happens When a Module is Disabled? 520
UserDevelopmentData 521
BundlingExtensionLibraries 521
ReferencingLibraries withClass-Path 522
UsingAutoload LibraryModules 523
Ad-Hoc Resources and ModuleInstaller Validation 525
InternationalizationandAccessibility 526
I18NandL10N 526
A11Y 528
JavaHelp—WritingandDistributing 529
Creatinga HelpSet 529
Adding a Help Setto NetBeans 531
AddingContextHelp 534
SeparatingHelp fromCode 535
SupportingUser-Level JavaAPIs 535
Supplyinga ParserDatabase 535
BundlingJavadoc 536
Adding to the Default Classpath 537
Templates 538
BeanInstallation 539
Creating theModule JAR File within the IDE 540
Creating a Build ScriptUsing Ant 540
Producingthe .nbmFile 541
Publishing Using the Update Center 543

Using ErrorManager to Log Problems 545
Testing 547
17. Building Your Distributionof NetBeans
Do You Need YourOwn Distribution? 549
Licensing 550
SelectingaBaseline 550
GettingtheSources 551
How to Customize the Build Process to Add Your Modules 552
Adding Modules to a“Stock” Distribution 553
CreatingPreconfiguredSettings 555
Branding 555
Implementing Branding on a Distribution 556
Simple Branding: Text Stringsand Images 557
Configuration Branding: Menu Bar,Workspaces, … 558
AdvancedBranding: PatchingBehavior 564
A. A Tour of Existing Modules to Use and Learn From
Modules thatExpose Functionality Your Module Might Need 569
TheXMLModules 569
TheEditor 570
Version Control—the VCS Core Module 570
RemoteFS 571
TheAntModule 571
TheJavaModule 571
DebuggerCore 572
J2EEServer 572
FormEditor 572
HTTPServerModule 572
ClassfileReaderModule 572
The Metadata Repository—a Whole Host of APIs 572
Socket-Based Editor Support—the ExternalEditor Module 573

Incidental APIs, Utilities and Extensions 573
TheUtilitiesModule 573
APIExtensions(openidex) 573
Modules which Make Good Examples for Things You May Need to Implement 574
Annotations and Dynamic Editor Tool Tips—the Ant Module and the Debugger Core Module
574
Adding Information to the View of Java Sources—the Beans Module 574
Adding a Debugger Type—theApplet Module 574
Multiplexing DataObjects,and Complex Cut/Copy/Paste Support—the Properties Module 574
Working with Network Protocols to Access Files—JavaCVS and RemoteFS 574
Domain-Specific XML Support—the Tomcat and Ant Modules 575
Stretching the Limits—the Web Modules 575
Complex Syntax Coloring—the JSP Module 575
Multi-Stage Compilation—the JSP, RMI, and CORBA Modules 575
Bridging to an Entirely Different Build System—the Ant and Makefile Modules 575
Use of the Compiler Infrastructure for Non-Compilation Tasks—the JAR Packager Module 576
Execution—the Applet and JSP/Servlet Modules 576
Custom Hyperlinkingin the Output Window—the Ant Module 576
Specifying Windows, Workspaces and Components Using XML—the Core Window System
and the Form Editor Module 576
Complex Work with MIMEResolvers and Multi-File DataObjects—the CPP Module 577
Cut/Copy/Paste—Data Transfer Support for Complex Elements—the Ant and Java Modules
577
Interconversion between Different Types of Clipboard Contents—JNDI, CORBA, and RMI 577
Integrating Other Programming Languages—the C++/Fortran, Scripting, and WebL Modules
577
Fancy Footwork with Nodes—theJava Module 578
Adding Nodes to the Runtime Tab in the Explorer—the RMI, CORBA, JNDI, and Database
ExplorerModules 578
The Bare Essentials of Non-Data-Driven Nodes—the System Properties Module 578

Wizards—the CORBA,Java and New Module Wizard Modules 578
Embedding Property Panels into Wizards—the Java Module 578
Complex Explorer Views—the DebuggerCore Module 578
Enabling/Disabling Sets of Actions based on Context—the VCS Core Module 579
B.Useful UtilityClasses
XMLUtilities 580
org.openide.xml.XMLUtil 580
org.openide.xml.EntityCatalog 580
Visual Componentsand Extensions to Standard Swing Components 580
LookupImplementations 581
Threading 581
Miscellaneous Utility Classes in org.openide.util 581
SerializationHelpers 582
C.FuturePlans
DeclarativeInstantiation 583
UniformLookup 583
DatasystemsII 584
TheLooksAPI 584
DeclarativeActions 585
Deprecation ofIDE-Specific Functionality in the Open APIs 585
TheMetadataRepository 585
Standards Employed by the MDR 586
ProjectSupport 587
D. Working with Open-Sourceand NetBeans
Practices 589
Governance 589
Consensus 590
Howto GetInvolved 595
The Lifecycle of Module Development 600
Resources 602

CVS(Concurrent VersioningSystem) 602
Projects 602
MailingLists 602
Issuezilla 603
Interacting Effectively on Mailing Lists 604
E. AdditionalModules and Where to Find Them
Open-Source Modules Available via the Update Center 606
The Modules Marketplace on Flashline 606
IDEs thatare Distributions of the NetBeans IDE 608
Open-Source Application Projects Basedon NetBeans 609
Commercial Applications Built on the NetBeans Platform 609
Commercial Modules Available for NetBeans 610
Should You Create Your Own Update Server? 612
Glossary
List of Figures
3.1. MultiFileSystem merging constituent filesystems 264
3.2. Module adding XML layer to the system filesystem 265
3.3. Structure of thesystem filesystem 267
3.4. The system filesystem viewed from the Explorer window 268
3.5. Architectural domains underlying nodes 272
3.6. The menu configuration folders in the Options window 274
3.7. The File menu with the Build action added to it 275
3.8. The File menu with a custom executable class added to it 277
4.1. Mappingof files to Java class instances 289
4.2. Mappingfrom files to InstanceDataObjects to lookup 290
4.3. Anatomy of a node 296
4.4.Explorerviews—BeanTreeView 300
4.5.Explorerviews—ChoiceView 301
4.6.Explorerviews—IconView 301
4.7.Explorerviews—ListView 302

4.8.Explorerviews—ListView 302
4.9. A “Pseudo-Windows Explorer” mock-up created using IconView and ContextTreeView 302
4.10.Explorerviews—TreeTableView 303
4.11. Modes, TopComponents and Nodes—anatomy of the Explorer window 307
4.12. NetBeansclass loaders (with three modules installed) 313
6.1.Bean Browser—masterview 326
6.2. BeanBrowser showing list of registered ServiceTypes 328
6.3. Browsing the live window system in the system filesystem 332
7.1.The FileSelectorcomponent 346
7.2. The improved FileSelector component 348
7.3. Thefinal version of the QuickPanel component 356
8.1.Mail filesystem:BeanInfo 370
8.2.Mail filesystem:SelectServerPanel 373
8.3.Mail filesystem:SelectRootFolderPanel 376
8.4. Mail filesystem: IMAP Mail Server template 380
9.1. Mailfilesystem: property sheet of a message 385
9.2. Mail filesystem: raw Filesystems view of a mail server 388
9.3. Mail filesystem: Message Servers in the Runtime tab 393
9.4. Mailfilesystem: relationships among nodes and objects 397
9.5. Mail filesystem: threaded view 399
9.6. Mail filesystem: mail workspace 404
10.1. Minicomposer: editing a score as text 413
10.2. Minicomposer: using the Musical Score template 418
11.1. UML of theScoreSupport lifecycle 426
11.2. Minicomposer: two-way editing of score files 432
13.1. Minicomposer: audio players in Options window 456
13.2. Minicomposer: choosing to use an external audio player 458
13.3. Minicomposer: configuring an external audio player 459
13.4. Minicomposer: selecting the audio player process 460
13.5. Minicomposer: settings displayed in Options window 465

14.1. Minicomposer:parent and child nodes with keys 472
14.2. Minicomposer: ScoreChildren lifecyclestate diagram 474
14.3. Minicomposer: score file with note subnodes 476
14.4. Minicomposer: unrecognized tone dialog 478
14.5.Minicomposer: in-placerename 478
14.6. Minicomposer: add newnote dialog 481
14.7. Minicomposer: property sheet for a note 484
14.8. Minicomposer: The ChangeOrder option 486
14.9. Minicomposer: Reordering the nodes 487
14.10. Minicomposer: moving anote up 488
14.11. Minicomposer: clipboard with three notes copied 490
14.12. Minicomposer:changing clipboard contents with convertor active 496
16.1.Autoloadmodules 524
16.2. Minicomposer: JavaHelp start page 531
16.3. Minicomposer: Help Sets submenu 533
16.4. Javadoc automatic (declarative) mounts 537
17.1. Branding: patching thecore bundle 558
17.2. Branding: masking a file 561
17.3. Branding a layer with the Open APIs Support module 563
17.4. Showingthe system filesystem in the Explorer 564
List of Examples
3.1. Addinga .instance to the System Filesystem 264
3.2. Writing to theStatus Bar 282
4.1. Sample Module Manifest—the Debugger Core Module 288
4.2. A Simple XML Layer Declaring a Java Instance 289
4.3. Specifying a Static Factory Method for Instances in a Module Layer 291
4.4. Factory Method to Instantiate a Class from a .instance File 292
4.5. Specifying the Class that Will Be Created in a Layer 292
4.6. Specifying Initialization Data for a Java Instance Declared in a Layer 292
4.7. Simple Factory Method for an XML Layer Instance 293

4.8. Complex Factory Method for an XML Layer Instance 293
4.9. Declaring File Contents Using URLs in XML Layers 293
4.10. Ordering attributes inXML layers 294
5.1. MyAction.java for HelloWorld Module 320
5.2. Bundle.properties for HelloWorld Module 321
5.3. mf-layer.xml for HelloWorld Module 322
5.4. Manifest for HelloWorld Module 322
6.1.Locating aSystemOption 330
7.1.QuickPanel:FileSelector.java 344
7.2.QuickPanel:FilesOnlyChildren.java 347
7.3. QuickPanel: MethodSelector.java—Creating a Listener to Monitor the Active TopComponent 349
7.4. QuickPanel: MethodSelector.java—Full Listing TopComponent 351
7.5.QuickPanel:QuickPanel.java 354
7.6.QuickPanel:ShowQuickPanelAction.java 354
7.7. QuickPanel:layer.xml—Creating the QuickPanel Module’s XML Layer 355
7.8. QuickPanel: MANIFEST.MF—the QuickPanelModule’s Manifest 356
8.1. InfoImpl Implementation inside MailFileSystem.java 360
8.2. ListImpl Implementation inside MailFileSystem.java 362
8.3. ChangeImpl Implementation inside MailFileSystem.java 362
8.4. AttrImpl Implementation inside MailFileSystem.java 363
8.5. MailFilesystem: MailFileSystem Implementation as a Whole 364
8.6. Mail Filesystem: MailFileSystem.java Added Inner Class to Support Status 368
8.7.Mail Filesystem:MailFileSystemBeanInfo.java 369
8.8.Mail Filesystem:SelectServerPanel.java 372
8.9. Mail Filesystem: SelectRootFolderPanel.java(Panel Implementation) 374
8.10. Mail Filesystem: SelectRootFolderPanel.java (MailFolderNode Inner Class) 375
8.11.Mail Filesystem:ConnectionWizardIterator.java 377
8.12. Mail Filesystem: Initial layer.xml 379
8.13. Mail Filesystem: Initial Module JAR Manifest 379
8.14. Mail Filesystem: Initial Bundle.properties 379

8.15.Mail Filesystem:new.xml 380
9.1. Mail Filesystem: Module JAR Manifest Including Data Loaders 381
9.2.Mail Filesystem:MailDataLoader.java 382
9.3.Mail Filesystem:MailDataObject.java 383
9.4.Mail Filesystem:MessageBodyEditorSupport.java 383
9.5.Mail Filesystem:MailDataNode.java 384
9.6.Mail Filesystem:MultipartMessageDataLoader.java 386
9.7.Mail Filesystem:MultipartMessageDataObject.java 387
9.8.Mail Filesystem:MultipartMessageDataNode.java 387
9.9.Mail Filesystem:MessageFileSystemsNode.java 388
9.10.Mail Filesystem:MessageFileSystemsChildren.java 390
9.11.Mail Filesystem:GeneralFolderHierarchyChildren.java 390
9.12. Mail Filesystem: Initial MessageFolderHierarchyChildren.java 391
9.13.Mail Filesystem:MessageNode.java 392
9.14. Mail Filesystem: Module JAR Manifest with Node Registration 393
9.15.Mail Filesystem:ViewTypeOption.java 394
9.16.Mail Filesystem:view-type-option.xml 395
9.17. MailFilesystem: MessageFolderHierarchyChildren Changes for Threaded View 395
9.18. Mail Filesystem: Signatureof MessageThread.java 396
9.19.Mail Filesystem:ThreadChildren.java 397
9.20.Mail Filesystem:MessagesExplorer.java 401
9.21.Mail Filesystem:mail.xml 402
9.22.Mail Filesystem:explorer.xml 403
9.23.Mail Filesystem:messages.xml 403
9.24.Mail Filesystem:messages-def.xml 404
10.1.Minicomposer: Initialminicomposer.mf 407
10.2.Minicomposer: Initialsrc/org/netbeans/examples/modules/minicomposer/Bundle.properties 407
10.3.Minicomposer: Initialsrc/org/netbeans/examples/modules/minicomposer/layer.xml 407
10.4.Minicomposer:build.xml 408
10.5.Minicomposer: Initialsrc/org/netbeans/examples/modules/minicomposer/mime-resolver.xml 410

10.6.Minicomposer: Initialsrc/org/netbeans/examples/modules/minicomposer/ScoreDataLoader.java 410
10.7.Minicomposer: Initialsrc/org/netbeans/examples/modules/minicomposer/ScoreEditorSupport.java 412
10.8. Minicomposer: src/org/netbeans/examples/modules/minicomposer/ScoreDataObject.java with Editor Sup-
port 413
10.9. Minicomposer: Public Signatureof src/org/netbeans/examples/modules/minicomposer/Score.java 414
10.10. Minicomposer: Public Signature of src/
org/netbeans/examples/modules/minicomposer/LineInFromScore.java 415
10.11.Minicomposer:src/org/netbeans/examples/modules/minicomposer/ScoreExec.java 416
10.12.Minicomposer:src/org/netbeans/examples/modules/minicomposer/DescForTemplate.html 417
11.1.Minicomposer:src/org/netbeans/examples/modules/minicomposer/ScoreCookie.java 419
11.2.Synopsis ofEditorCookie 420
11.3. Synopsis of Selected Methods in SourceElement 421
11.4. Minicomposer: src/org/netbeans/examples/modules/minicomposer/ScoreSupport.java (Text# Structure) 422
11.5.Minicomposer:src/org/netbeans/examples/modules/minicomposer/ScoreOpenSupport.java 427
11.6. Minicomposer: src/org/netbeans/examples/modules/minicomposer/ScorePanel.java (Creation and Persis-
tence) 429
11.7. Minicomposer: src/org/netbeans/examples/modules/minicomposer/ScoreDataNode.java with Parse Support
433
12.1.Minicomposer:src/org/netbeans/examples/modules/minicomposer/SampledAudioCompiler.java 438
12.2.Minicomposer:src/org/netbeans/examples/modules/minicomposer/SampledAudioCompilerGroup.java 439
12.3.Minicomposer:src/org/netbeans/examples/modules/minicomposer/SampledAudioCleaner.java 440
12.4.Minicomposer:src/org/netbeans/examples/modules/minicomposer/ScoreCompilerSupport.java 442
12.5. Minicomposer: mime-resolver.xml withCompiler Support 445
13.1.Minicomposer:src/org/netbeans/examples/modules/minicomposer/InternalPlayer.java 449
13.2.Minicomposer:src/org/netbeans/examples/modules/minicomposer/InternalPlayerBeanInfo.java 451
13.3.Minicomposer:src/org/netbeans/examples/modules/minicomposer/ExternalPlayer.java 452
13.4.Minicomposer:src/org/netbeans/examples/modules/minicomposer/ExternalPlayerBeanInfo.java 453
13.5.Minicomposer:src/org/netbeans/examples/modules/minicomposer/internal-player.xml 455
13.6.Minicomposer:src/org/netbeans/examples/modules/minicomposer/external-player.xml 456
13.7.Minicomposer:src/org/netbeans/examples/modules/minicomposer/ScoreExecSupport.java 457

13.8.Minicomposer:src/org/netbeans/examples/modules/minicomposer/ComposerSettings.java 461
13.9.Minicomposer:src/org/netbeans/examples/modules/minicomposer/ComposerSettingsBeanInfo.java 463
13.10.Minicomposer:src/org/netbeans/examples/modules/minicomposer/option.xml 465
14.1.Minicomposer:src/org/netbeans/examples/modules/minicomposer/ClipLengthProperty.java 468
14.2.Minicomposer:src/org/netbeans/examples/modules/minicomposer/ScoreChildren.java 471
14.3. Minicomposer: src/org/netbeans/examples/modules/minicomposer/NoteNode.java inBasic Form 474
14.4. Minicomposer: src/org/netbeans/examples/modules/minicomposer/NoteTransfer.java with NewType 479
14.5.Minicomposer:src/org/netbeans/examples/modules/minicomposer/NoteProperty.java 481
16.1. Dependency Specifications in Modules 512
16.2. Providing services toa client 513
16.3. Specifyinga required service in a client 513
16.4.The modulemanifest 522
16.5.The packagemanifest 522
16.6.I18N: Basicsrc/org/module/SomeClass.java 526
16.7.I18N: Basicsrc/org/module/Bundle.properties 526
16.8.I18N: Basicsrc/org/module/Bundle_cs.properties 527
16.9.I18N: Incorrectsrc/org/module/SomeClass.java 527
16.10.I18N: Incorrectsrc/org/module/Bundle.properties 527
16.11.I18N: Revisedsrc/org/module/SomeClass.java 527
16.12.I18N: Revisedsrc/org/module/Bundle.properties 528
16.13.I18N: Revisedsrc/org/module/Bundle_cs.properties 528
16.14.JavaHelp:src/org/netbeans/examples/modules/minicomposer/help-set.xml 529
16.15.JavaHelp:src/org/netbeans/examples/modules/minicomposer/help-map.xml 530
16.16.JavaHelp:src/org/netbeans/examples/modules/minicomposer/help-contents.xml 530
16.17.JavaHelp:src/org/netbeans/examples/modules/minicomposer/help-set-ref.xml 531
16.18.JavaHelp:src/org/netbeans/examples/modules/minicomposer/help-main-page.xml 532
16.19.Bundling Javadoc:javadoc-mount.xml 536
16.20. Adding to the User Classpath: lib-mount.xml 538
16.21.Java Templates:SimpleRenderer.java.template 538
16.22. NBMs: Sample NBMFile Contents 541

16.23.NBMs: SampleInfo/info.xml 541
16.24. Update Center: SampleUpdate XML 543
16.25.Update Center:updates.settings 545
17.1. Adding a Module:Sample system/Modules/com-yourcorp-modulename.xml 554
17.2. Branding: …/Layer_macmod.xml with a New File 560
17.3. Branding: …/Bundle_macmod.properties with a New File 560
17.4.Branding:org/netbeans/modules/autoupdate/resources/info-UpdateAction_macmod.html 567
Foreword—by James Gosling
What attracts me to NetBeans is the fact that, contrary to the marketing material, it is not an IDE—not an Integrated
Development Environment. It is better described as a DDE—a Disintegrated Development Environment. What I mean
is that, at its most basic, NetBeans is just a spine. It is a framework that development environment components can be
plugged into. When you run NetBeans, almost everything you see is a plug-in.
One of the problems of the development environment world has been that, traditionally, things have not been done this
way. Many people have built specialized tools (for example, finite state thread modeling tools), but they have had a
hard time making progress with them. Individual tools are only a part of the software production process, so those who
make the tools have often ended up attempting to build a supporting environment, which is a daunting and expensive
task.
The key to making any framework successful is having a set of interfaces that define it—contracts between the two
sides of the interface so that each side knows what is expected of it, and what it should expect of the other side. This
notion of building frameworks out of sets of interfaces is central to object-oriented programming and one of the most
important patterns in the use of Java.
This book defines the framework that is NetBeans. It is somewhat daunting, but the technology of development envi-
ronments is rich in a certain unavoidable complexity. Through this book and the NetBeans platform, you will be able to
build your own tools to handle whatever specialized problem you may have with software development, and have the
result integrate into the whole development process. I know you’ll have fun with it. I certainly have!
James Gosling
ccxlviii
[1] According to the American Heritage™ Dictionary of the English Language, Fourth Edition, API is also an acronym for Asian and Pacific Is-
lander. Readers of this book may safely assume we are referring to Application Programming Interface.
Chapter 1. Introduction

Table of Contents
Who Should Read this Book? 249
What’sDifferent aboutNetBeans? 250
The Core and theOpen APIs 250
TheLicense 251
Open-Source 252
Thenetbeans.org WebSite 252
NetBeansfor BeanCounters 254
Getting andInstalling the Open APIs Support Module 255
LifeisChange 256
Source code for the examples 256
Who Should Read this Book?
There any number of reasons to develop extensions to NetBeans: Perhaps you are a developer, working on a project
that has some unique needs (such as deployment to a particular application server or use of a code analysis tool), and
you use NetBeans and would like to have support for that tool integrated into your development environment. Or you
could have a development tool that you would like to integrate with NetBeans and sell as an extension.
Or you could simply be embarking on a project to create a large desktop application, and you can save several person-
years by using the NetBeans core without its development-tool-specific functionality to handle the menus, windowing,
file access, configuration and browsing aspects of your application.
This half of the book is about writing modules to plug into NetBeans to extend its functionality. So it is of particular in-
terest to people developing or using tools for software development, people developing desktop applications in Java, or
anyone who simply uses the NetBeans IDE and would like to change the way something works. We assume you have
some familiarity with NetBeans as a development tool and its user interface components and with the Java language.
The design of NetBeans is also a great example of well-crafted object-oriented architecture. Odds are good this book
will affect the way you think about how to build software.
Extensions to NetBeans are developed by writing Java code to the NetBeans Open APIs. API stands for Application
Programming Interface[1], and is the common industry term for interfaces a program exposes to allow other programs
or components to interact with it.
There is extensive documentation of the NetBeans APIs available in Javadoc and prose format on the NetBeans web
site. This book should act as a complement to the Open APIs reference documentation, not as a replacement. Javadoc is

a very good tool for explaining APIs using their package and class structures as its organizing principle, and the
Javadoc set for NetBeans contains excellent prose overviews of each API that cover how to use them. But people do
not necessarily think in the same structure that a class hierarchy has—generally, they start with a problem to solve.
With this book we intend to provide a task-oriented guide to using these APIs. We hope to leave you with a rich under-
standing of how NetBeans works and the philosophy guiding that design.
Chapter 1. Introduction
249
What’s Different about NetBeans?
In the form most of the world knows it, NetBeans is an integrated development environment (IDE) written in Java. Be-
ing written in Java, it should (and generally does) run on a Java 2 JVM, version 1.3 or higher. What makes NetBeans
different from other development environments is its flexibility. While the first incarnation of it was a tool for Java pro-
gramming, over three generations of its architecture, it was redesigned to be a generic tools platform to support devel-
opment in any language, not just Java. The key is its modular design. There is a basic, generic application runtime that
does not even know it is an IDE, which is implemented in the NetBeans core. Extensions to this framework in the form
of modules are what actually make it an IDE. The code editor, the Java language support—almost everything you see
in NetBeans is implemented as a pluggable module.
This means that not only can NetBeans be used as a tool for Java development; people can use the NetBeans core with
only their own modules installed to build a desktop application that might have nothing to do with software develop-
ment. A number of companies and individuals have done this, and the result is (at the time of this writing) four com-
mercial IDEs which are NetBeans plus some custom modules (Sun’s Forte for Java, Compuware’s OptimalJ, Compaq
NetBeans and Zucotto’s Whiteboard) and applications running the gamut from a CAD tool for designing coal mines
(ECSI Minex [ to a tool for managing a hair salon (SalonTango), to a music composition and
notation tool (Project XEMO [ By the time you read this, there will no doubt be many more.
For an up-to-date list, see the netbeans.org third party page [ />Since all of the IDE-like behavior of NetBeans is implemented in the form of plug-in modules, you can use the Net-
Beans core to handle a lot of the grunt work involved in writing a desktop application. Most applications need access to
files, need to provide menus and toolbars and windows and store settings. Having the implementation of these things
handled for you solidly by the NetBeans core can save a lot of development time and effort. NetBeans is to the desktop
much as an application server is to a server computer—where an application server provides an execution context for
arbitrary Enterprise Java Beans, NetBeans provides an execution context for arbitrary modules. Both frameworks are
designed to handle commonly needed tasks so you can concentrate on the actual logic.

The Core and the Open APIs
The architecture of NetBeans breaks down into two major sections: The core (also referred to as the application run-
time) and the Open APIs. The core plus the Open APIs makes up the NetBeans Platform. These are represented in the
org.netbeans.core.* and org.openide.* Java packages, respectively, in the source code for NetBeans. Bi-
nary libraries of these packages are part of your installation of NetBeans in the files $NB_HOME/lib/core.jar and
$NB_HOME/lib/openide.jar. The core implements many interfaces defined in the Open APIs and is NetBeans’
runtime engine. The Open APIs are the toolset available to module authors who want to write modules to implement
functionality that will run inside of NetBeans. A module is a .jar (Java ARchive or JAR) file which contains the
module’s Java classes and a manifest file which describes the module, and how to install and uninstall it, to NetBeans’
runtime.
As for any application, for an IDE such an architecture has a number of advantages. First and foremost is the ability to
support multiple languages. Another significant advantage is the ability to wrap the functionality of other development
tools and present it within the IDE. The simplest example of this kind of wrapping is the way external compilers and
Java virtual machines can be used for compilation and execution by defining services which launch an external process
and parse and present the output of that process (e.g. compiler error messages). A more complex example would be the
integration of a pre-existing UML tool to allow seamless interaction with it through NetBeans’ user interface.
A number of the elements of NetBeans, such as the Filesystems, Nodes and Explorer APIs, can also be used as stan-
dalone libraries for client- and server-side Java applications outside of NetBeans. In a sense, NetBeans is a set of li-
braries. [2]
Chapter 1. Introduction
250
[2] As this book is being written and NetBeans 3.4 is in development, one of the thrusts of that work is to decompose the core into smaller, indepen-
dent libraries implementing specific APIs. This work will further enable applications to use and distribute only that functionality which they need.
A caveat to this type of design is that no module should call functionality that does not appear in the Open APIs: for ex-
ample, getting an object with an interface declared in the Open APIs and then casting to a core implementation class to
access some method that isn’t defined in the APIs. The contract of an API is to provide access to functionality that will
continue to work even if the underlying implementation is replaced. This means that there is no guarantee that anything
not declared in the Open APIs documentation will be present in future versions of the IDE, and any code using the core
implementation classes directly is liable to be break in some future version of NetBeans. If there is something you need
to do that is inconvenient or not possible with the APIs, ask on the NetBeans mailing lists

[ if there is a different approach you should take, or if there is not,
file an enhancement request in the bug tracking tool [ on the netbeans.org
web site.
The License
Licensing of software and source code determines what other people can and cannot do with that software. The source
code to NetBeans is available under a license called the Sun Public License, which is very non-restrictive. Basically
what this allows you to do is:
License compatibility
There are a lot of religious arguments about software licenses, and this book is not going to take a position with regard
to them. There are cases where software licenses are “encumbered”—a license places certain obligations on the author
of any code using that license, the users of code written under that license, and in some cases, anyone who distributes
code under more than one license as a single product. There are situations in which the licenses of two products, if dis-
tributed together, place contradictory demands on either the author or the user. These are termed incompatible licenses.
The GNU General Public License (GPL) is one such case—it requires that people distributing software under other li-
censes along with GPL software apply the the GNU license to all software that is packaged with it (requiring them to
give away the source code). There is a possibility of something called “dual licensing” which allows users and vendors
to choose which license applies where, but this also lands in completely uncharted legal waters.
Because the GPL (requiring all source code to be “free”) and the license NetBeans is under (which allows you to give
away what you want and sell what you want) are not compatible, it is the requirement of Sun Microsystems’ lawyers
that incompatibly licensed software not be hosted on netbeans.org. Since Sun foots the bill for the site, this legal advice
is taken seriously.
If you decide to contribute a module to netbeans.org, the way to do this is simply to use the same license
[ as the rest of the NetBeans sources, as detailed in the section called
“The License”.
Please bear in mind that the authors of this book are not lawyers, and none of the licensing-related text in this book
should be construed as legal advice. If you are writing software and have questions as to how to license it, consult qual-
ified legal counsel.
• Use NetBeans to create commercial or non-commercial software.
• Build modules that integrate with NetBeans and sell them or give them away.
• Redistribute NetBeans either for free or for sale, with your own branding, custom configuration, with additional

modules you supply, and removing any modules you don’t want in your distribution.
• Use parts of NetBeans code (e.g., the Filesystems library, or the core) in your own applications, commercial or non-
Chapter 1. Introduction
251
commercial.
The Sun Public License (SPL) is a minor variant of the Mozilla Public License (MPL), the license Netscape created
when it released the sources to its web browser. The only significant differences are that the word Netscape is replaced
by Sun Microsystems and the license covers open-sourcing the documentation as well, which Netscape did not explic-
itly do. For the full details (including a diff with the MPL) see />[ />Open-Source
NetBeans is an open-source project hosted at [ What this means is
that the source code for the entire IDE is available for download. A principle of open-source is open communication,
and design discussions happen on the public mailing lists at netbeans.org. The site is divided into various subproject
sites (e.g. [ for the various modules that are part of NetBeans. De-
cisions are reached by consensus on the mailing lists (see the section called “The mechanics of consensus” for an ex-
planation of how this works in practice); there is a governance board consisting of two members chosen by the commu-
nity on the mailing lists, and one appointed by Sun Microsystems (which donated the code that started the project, em-
ploys many of the developers of NetBeans, and financially supports the site’s infrastructure). In the event of an in-
tractable dispute, the board exists to make decisions. In practice, issues of such magnitude are extremely rare.
It being an open-source project, you can also get involved in the ongoing development of NetBeans. Code contribu-
tions, patches and bug fixes are always welcome. To learn more about getting involved in the NetBeans project, see the
contributions index [ />If you write a module for NetBeans that you do not intend to sell, but which would be generally useful to the commu-
nity at large, you have the option of contributing that module to netbeans.org. Please do! Assuming a compatible li-
cense (see License compatibility), the sources can be hosted in CVS, mailing lists set up for discussing the ongoing
maintenance of that code and bug categories for your module created. If you want to do this, send a proposal to the
<> mailing list about your module, and assuming the consensus is that your module would
be a good addition to the NetBeans project, follow the contribution instructions on the web site. See the section called
“The Lifecycle of Module Development” for details.
Note that contributing a module involves an ongoing commitment to maintain it— it is never a good idea to contribute
a module as a way of abandoning it.
The netbeans.org Web Site

The main pages of the NetBeans web site can be found at [ and in-
clude overviews of NetBeans, news from the various subprojects on the site, documentation, bug tracking and indexes
to interesting documents from subprojects, such as new feature proposals, how-to’s and FAQs.
The site is hosted using an open-source infrastructure called SourceCast, and is hosted by a company called CollabNet,
under contract to Sun Microsystems. As mentioned, NetBeans is modular—there are a lot of subprojects that are part of
NetBeans, and if they were all hosted on the top-level web site, the number of documents would quickly become un-
manageable. Instead, a module or set of modules has its own web pages on a virtual host—a virtual web site with a dif-
ferent name, e.g., [ for the pages relating to the code editor. Each
module project may have its own mailing lists for development discussion, user questions and such. Not all do—it is at
the discretion of the maintainers of that particular project whether their project needs its own mailing lists. Most
projects are small enough that discussion should simply happen on the top-level user and development mailing lists.
There is a convention for posting messages of interest only to developers of a single module or topic of interest to a mi-
nority of members of a mailing list: Put the topic in square brackets, e.g. [performance] Caught exceptions
Chapter 1. Introduction
252
on startup.
There are also several “meta-projects” which are not really modules in their own right, but exist as jumping-off points
for related modules which have their own virtual hosts. An example of this is das.netbeans.org
[ DAS stands for “Distributed Application Support— the project is mainly a homepage for get-
ting to modules such as CORBA and RMI support. These meta-projects serve to group related modules and keep the
initial list of projects that a visitor to the site is confronted with from being intimidatingly large.
Additionally, there are a number of sub-projects which are not specifically coding-related, such as the qa.netbeans.org
[ quality assurance sub-site, which has graphs of the bug counts of recent builds over time, and
other useful resources. Another interesting site of this type is ui.netbeans.org [ maintained by
Sun’s team of human interface engineers who work to ensure that the user interface to NetBeans is usable and consis-
tent, and do work such as icon and interaction design.
Registration
While open-source sites should and generally do have low barriers to entry, there are some functions of the site that re-
quire you to register and get a login ID and password. These include filing bug reports, signing up for mailing lists and
of course, CVS (Concurrent Versioning System, the tool for storing and accessing source code) and administrative ac-

cess. One of the purposes for this mechanism is so that people who are the maintainers of a project can have access per-
missions to manage their own mailing lists and project sub-site, and so that when you file a bug, you’ll get an auto-
mated email if it’s fixed or its status changes.
Bug tracking
Bugs are tracked using Issuezilla, an enhanced version of the Mozilla project’s bug tracking tool Bugzilla. Issuezilla
lacks some bells and whistles, and has a somewhat intimidating query interface, but is generally usable. Eventually,
CollabNet plans to replace it with a new system, but the timetable for this is still undetermined at the time of this writ-
ing. Items in Issuezilla are categorized as defects, enhancement requests or tasks.
There is a simple query interface available at />[ Anyone can anonymously query the bug database; to enter new items
in Issuezilla, you will need to register and get a login ID.
Ways to participate
Open-source is not just about writing code! There are a huge number of ways to participate in an open-source commu-
nity—the simplest is to download a copy of the software and join a mailing list. Open-source is about people building
software more efficiently by everyone benefiting from each other’s expertise. Filing enhancement requests and bug re-
ports, and asking and answering questions on mailing lists are as important forms of participation as writing code. In
parallel with reading this book, we encourage you to subscribe to the <>,
<> or <> mailing lists and get a sense for yourself of
what the NetBeans community is like. See the NetBeans Mailing Lists
[ page to sign up.
The netbeans.org FAQs and mailing lists
The mailing lists on netbeans.org are particularly useful supplements to the contents of this book. Many subprojects
have their own development mailing lists for discussion of development on that particular project (e.g.
<>).
Chapter 1. Introduction
253
Another useful resource to supplement this book is the <> mailing list. The
openide.netbeans.org [ project is where the ongoing evolution of the Open APIs happens,
and if you have questions about how to do something or the usage of a particular part of the Open APIs that you cannot
find the answer to, the APIs documentation or this book, that is the place to ask. As with any mailing list of this type,
please check the Frequently Asked Question (FAQ) pages at />[ You may well find the answer to your question there.

You can also read and post to the netbeans.org mailing lists via a newsreader, by connecting to
news://news.netbeans.org [news://news.netbeans.org]. Note that posts from unregistered email addresses are moder-
ated—they need to be approved by someone, so there may be a delay before your first post appears if you post via a
newsreader or using an email address in the From: field of your email other than the one you registered with. An in-
creasing amount of “spam” mail is sent to the netbeans.org mailing lists daily—moderators make sure this unwanted
email does not end up cluttering the mailboxes of everyone on the mailing lists, hence the need for this protection
mechanism.
Being on Topic
Mailing lists exist to cover specific areas of NetBeans design and use, and it’s helpful to know which list is for what.
The value of a mailing list to its participants is proportional to the amount the conversation stays on topic. Here is a
breakdown of the major top-level netbeans.org mailing lists:
• <>—The main user community mailing list, for questions about using NetBeans, dis-
cussion of problems, etc.
• <>—Development of NetBeans, both modules (those that don’t have their own devel-
oper lists) and the core.
• <>—Usage and ongoing evolution of the Open APIs. If you have a question
about something in the APIs that you can’t find an answer to, this is the place.
• <>—Discussion of non-code aspects of the NetBeans project (the web site, gover-
nance, etc.).
• <>—A fully moderated (all posts must be approved by a moderator) list for Net-
Beans project announcements.
• <>—A fully moderated list for companies that want to hire people with NetBeans ex-
pertise to post job listings on, and for people with NetBeans expertise to post resumes. Note that this is not a gen-
eral jobs list! If a resume or a job listing has nothing to do with NetBeans, it will not be approved to the list.
Another useful resource is the NetBeans weekly newsletter, which is run by volunteers and mailed every Monday to the
<> mailing list. It contains summaries of what’s happened with NetBeans for the
past week, any new contributions and links to web archives of interesting conversations from the public mailing lists.
For a listing of the top-level mailing lists, and a form to allow you to subscribe to them, go to
[ To
subscribe to individual project mailing lists, follow the links from the home pages of the projects you are interested in.

As with any set of community mailing lists, it pays to lurk a little while before posting, to get a feel for the community
and a sense of what subjects are appropriate to each mailing list.
NetBeans for Bean Counters
Chapter 1. Introduction
254
At the time of this writing (May 2002), the NetBeans open-source project has been running for two years. Here are
some interesting statistics about it:
• The oldest code in the codebase is from 1997, from NetBeans 2.0
• The codebase is currently around 800,000 lines of code
• There have been 386,300 downloads of NetBeans
• There have been over a million downloads of Sun Microsystems’ distribution of NetBeans, Forte™ for Java
• The average number of messages on all the top-level mailing lists combined is around 2000 messages per-month
• The combined subscribership count of all top-level mailing lists is about 2000
Getting and Installing the Open APIs Support Module
Not only are there tools to make general Java coding easier within NetBeans—there is also a module that provides a
substantial amount of help with building extensions to the IDE. This is the Open APIs Support module. It includes:
• Templates for various kinds of objects commonly subclassed in writing extensions, with helpful comments and ex-
amples.
• The NetBeans Open APIs Javadoc and prose reference documentation, installed in the IDE’s Javadoc repository, so
the documentation can be viewed and searched from within the IDE.
• Execution services for commonly used interface components—so instead of having to install a component you’re
creating into the IDE, you can simply execute the component class.
• The Bean Browser, which is rather like the traditional explorer tree, but allows you to browse objects within the in-
ternal hierarchy of objects in the IDE which are not normally exposed by the user interface.
• Support for dynamically reloading modules for testing purposes—it would be awful to have to restart the IDE to
test each revision to one’s code
• Structural editing of XML layers (a configuration file most modules use) and graphical access to components and
attributes of modules under development in the Explorer tree.
You will need the Open APIs Support module to do many of the examples in this book. To get the module:
Getting the Open APIs Support module using the Update Center

1.
Make sure you have a working Internet connection to download the module.
2.
Select Tools | Update Center off the main menu.
3.
If you are behind a firewall, click the Proxy Configuration button and enter the proxy configuration information.
[3]
Chapter 1. Introduction
255
[3] If you are behind a SOCKS firewall, you will need to pass the proxy information to the JVM the IDE is running in. You need to do this
when you start the IDE, e.g. runide.sh -J-DsocksProxyPort=1080 -J-DsocksProxyHost=socksproxy.foo.com. Note
that even if you are behind a SOCKS firewall, you should still be able to use a simple HTTP proxy if one is available—so this is seldom neces-
sary. If you will need to use a SOCKS proxy every time you run NetBeans, create or edit the file called ide.cfg in $NB_HOME/bin to con-
tain the above line switches.
4.
Follow the instructions in the Update Center wizard and wait for it to check for new modules.
5.
Soon you will see a wizard pane with a list of modules you can add. Select the Open APIs Support module and the
Open APIs Support with Ant module from the list of available modules in the Extensions category, and click Add.
Click Next and follow the instructions on the remaining panels of the wizard, and the module will be downloaded
and installed.
For more information see the module’s web page [ />Life is Change
No piece of software is ever “finished,” and this is certainly true of NetBeans. We began writing the book at the begin-
ning of the NetBeans 3.2 release cycle; as this paragraph is being written, 3.3.2 is released, 3.4 is almost ready, and 4.0
looms on the horizon. There are ways to do things in NetBeans today that simplify things compared with the previous
release, and there are ways of doing things that were recommended for 3.2 that are now deprecated (but except if noted
in the upgrade guide bundled with the Open APIs documentation, still function). This will be true of future releases as
well. Where possible in this book, we project what changes are expected with 3.4 and further. This book primarily cov-
ers NetBeans 3.3.x, though major changes in NetBeans 3.4 are noted where appropriate.
This shouldn’t be cause for alarm—great effort is put into making NetBeans backward compatible. What it does mean

is that since technical books, particularly about software, are quickly obsolete, it is worth checking the upgrade guides
for module authors for versions subsequent to 3.3, and the published errata for this book. For details on the pending
changes known at this time, and the general direction in which the NetBeans APIs are evolving, see Appendix C.
Source code for the examples
As noted in the section called “Contents of the Accompanying Sources”, both sources and compiled module .nbm files
for the examples in this book can be found at somewhere [somewhere].
Chapter 1. Introduction
256
Chapter 2. History of NetBeans
Table of Contents
HumbleBeginnings 257
FirstSuccesses, FirstCosts 258
SunMeetsNetBeans 259
Open-Source,Fire-DrillStyle 260
NetBeansToday 260
The story behind NetBeans is an interesting one—as with any piece of software, story or work of art, it did not spring
fully formed from the forehead of anyone, but is tied up with the dreams, sweat and hard work of a number of people.
If you are anxious to get started coding for NetBeans, you can skip this chapter—but we encourage you to come back
and learn the human story behind the software you will read about in this book.
Humble Beginnings
In the fall of 1996, two Czech students were walking down a stairway at Charles University in Prague, one of them
named Jan (Ian) Formánek, when they encountered a group of fellow students in an argument. They were arguing about
the subject of their student project—it is a common practice in the Czech Republic for a group of computer science stu-
dents to do a year- to year-and-a-half-long project that gives them the experience of teamwork and creating something
worthwhile. This school had a stock list of projects, such as building and programming a robot. But these students
weren’t satisfied with any of them. They brought this up to their professor—they wanted to design their own project.
But what would it be? That was the subject of the argument.
When the dust cleared, they had settled on the ambitious task of building a visual C++ development tool along the lines
of Borland Delphi for the X Window System, and named the project Xelfi. Over the next few months they set about de-
signing an architecture, and trying to solve the issues of writing code portable enough that it would be usable on a wide

variety of systems.
Six months into the project, the group was faced with a crisis: They needed a stable, mature, free component library for
X, and after experimenting with many different component libraries, they could find none that would do the trick. One
of the students, Jaroslav (Yarda) Tulach, a mathematics major, had discovered Java while working on a side project.
Yarda suggested they shift the project to build a visual IDE for Java. “Good joke” was the response of the group. After
a month, they were still at a loss to find a component library when Ian brought the Java idea up again. This time, des-
perate, they agreed.
There was no reflection API in Java. There was no easy way to have an IDE manipulate Java components at design-
time. Bear in mind that we’re talking about Java 1.0.2. So this group of students took on the ambitious task of writing
their own visual component library, based on AWT, and building an IDE for it. In March of 1997, they named that li-
brary OpenJCOM, defended the Xelfi project, and, successful, graduated.
But some of the members of the project wanted to continue working on it. Not only was Xelfi the first IDE for Java, it
was the first IDE written in Java. The project was fun, they were freshly out of school, and it might have commercial
potential. The group formed a company under Ian’s name called Xelfi Technologies. They arranged a deal with a bank
for credit card processing (not an easy thing to do in the Czech Republic of 1997), and began selling Xelfi as shareware
on the web for $20 per license, at which was hosted on a web server owned by Yarda’s cousin’s
Chapter 2. History of NetBeans
257
firm. To their astonishment, the software made quite a splash—featured on the Gamelan web site, it attracted enormous
numbers of downloads from all over the world. The name of one of the downloaders was Roman Stan#k, a Czech en-
trepreneur. He sent them an email asking to meet and discuss business options.
It was the summer of 1997, the internet bubble that would burst in 2001 had just begun to inflate, and Roman had de-
cided he needed a new project. He stumbled across Xelfi on the internet. He had begun his career in mainframe pro-
gramming, later directed Sybase’s eastern European operations, and subsequently had started a successful PowerSoft
distributor which he had just sold to PowerSoft. Xelfi was interesting, new, and it had been a tremendous surprise to
discover its authors were right across town, in Prague. Since Ian and Yarda were competing for leadership of the Xelfi
project, they compromised on meeting with Roman together.
It was a warm June evening when Ian and Yarda, fresh out of college and flush with the success of their new enterprise,
clambered up the steps of the Dejvická metro station and met Roman in the lobby of the Hotel Diplomat. They emerged
with an agreement, and a surprising one: They would scrap Xelfi—by this time, the reflection API had been added to

Java by Sun. There was a now both a standard component architecture for Java and a way for an IDE to communicate
with it at design-time that could be used directly by an IDE. Xelfi would need to be rewritten from the ground up or
risk irrelevance. They would form a new company, an American-style internet startup. The purpose of that company
would be to create an IDE and an internet-enabled component framework resembling the Java Beans specification.
Yarda coined the name NetBeans, and the company had its name. The founders were Roman, Ian, Yarda and Helena
Stolka, brought in by Roman to handle marketing.
The shape of NetBeans today is very much a product of the tension between its two founders, Ian and Yarda—Ian,
quiet, reserved and piercingly intelligent, prioritizing usability and professionalism, and Yarda, outgoing, brilliant and
joyously outrageous, the abstract mathematics maven and architectural purist valuing a scalable, beautiful underlying
architecture over aesthetics. It is hard to imagine a more perfect combination, or a more difficult one! What you see
when you run NetBeans is, along with the contribution of the many talented people who have worked on the code, the
product of that creative tension.
First Successes, First Costs
In the fall of 1998, NetBeans released its first product, NetBeans Developer 2.0. By this time there were other Java
IDEs on the market, but NetBeans attracted a loyal following, favorable press, and particularly a good deal of interest
from the people in Sun Microsystems’ JavaSoft division. Sun had its own Java IDE, Java Workshop, but the project
had been plagued with shifting goals and design problems and was less than a wild success.
The plan the founders had was still to build a network-enabled framework along the lines of the Java Beans specifica-
tion once the first version of the IDE was released when, as with Xelfi’s component library, the specification for Enter-
prise Java Beans was released and began to get broad industry and media attention. The JDK 1.2 and Swing had also
been released, and the development environment would need to address these technologies as well. An interim release
called Developer X2 was planned and shipped early in 1999, supporting Swing with its new javax.swing packag-
ing, as planning for 3.0 began.
The recurring theme in the history of NetBeans is one of adaptation—the Java reflection API forcing the abandonment
of OpenJCOM, and, with Developer 3.0, scotching the plans for their own “net beans” and adopting Enterprise Java
Beans (the beta of NetBeans Developer 3.0 in the summer of 1999 was the first IDE on the market to support EJBs).
Take any engineer and show them a specification and they will probably tell you how they could write a better one—it
is to the real credit of the developers of NetBeans that they had the discipline to take the long view and use the avail-
able standards rather than reinvent the wheel.
But there was another crisis brewing—the architecture of the IDE itself. Clearly the direction they needed to go was for

it to become as generic as possible, so that new developments in technology would not continually obsolete the existing
design. Yarda and others had floated the notion of an extremely abstract, modular design. But this looked far too daunt-
Chapter 2. History of NetBeans
258

×