NetBeans Project Sample Module Tutorial
This tutorial demonstrates how to create a module containing your technology's project samples. You can easily make your technology's project samples
available once you have a module that
contains them—NetBeans IDE 5.x lets you create a binary that you can send to others, who can then install it through the
Update Center. Once the module is installed
in the IDE, the project samples are available in the New Project wizard.
The following topics are covered below:
Note: If a project sample relies on external JAR files and Javadoc, you can bundle them
into the module that bundles the project sample. It's very easy to do. For details, see the
NetBeans Project Template Module Tutorial.
Once the software is installed, this tutorial can be completed in 20 minutes.
For more information on working with NetBeans modules, see the
NetBeans Development Project home on the NetBeans website. If you have questions, visit the
NetBeans Developer FAQ or use the feedback link
at the top of this page.
Installing the Software
Before you begin, you need to install the following software on your
computer:
Creating the Module Project
- Choose File > New Project (Ctrl-Shift-N). Under Categories, select NetBeans Plug-in Modules. Under projects,
select Module Project and click Next.
- In the Name and Location panel, type AdditionalSamples in Project Name.
Change the
Project Location to any directory on your computer, such as c:\mymodules. Leave the Standalone Module radiobutton
and the Set as Main Project checkbox selected The panel should now look as follows:
Click Next.
- In the Basic Module Configuration panel, replace yourorghere in Code Name Base with myorg,
so that the whole code name base is org.myorg.additionalsamples.
Add a space to the default Module Display Name, so that it is changed to Additional Samples.
Leave the location of the localizing bundle and XML layer, so that they will be stored in a
package with the name org/myorg/additionalsamples. The panel should now look as follows:
- Click Finish.
The IDE creates the Additional Samples
project. The project contains all of your sources and
project metadata, such as the project's Ant build script. The project
opens in the IDE. You can view its logical structure in the Projects window (Ctrl-1) and its
file structure in the Files window (Ctrl-2). For example, the Projects window should now look as follows:
For basic information on each of the files above, see the
Introduction to NetBeans Module Development.
Bundling the Sample Application
- Right-click the project node and
choose New > File/Folder. Under Categories, select NetBeans Module Development. Under Projects,
select Project Template. Click Next.
- In the Select Project panel, select the project that you want to bundle as a sample, as shown below.
You can use the NetBeans IDE 5.x Quick Start Guide for Web Applications
to create a project or you can download it here.
Alternatively, use one of your own projects.
Click Next.
- In the Name and Location panel, type MyHelloWorldSample as the template name,
type Hello World Sample as the display name, and select Samples|Web in the Category drop-down list, as shown below:
- Click Finish.
The IDE does the following:
- creates a ZIP file containing your project
- provides a Java panel and an iterator used in the New Project wizard to create the sample
- provides an HTML file for the description displayed in the New Project wizard
- registers the sample in the XML layer file
- adds localization strings to the bundle.properties file
The Projects window should now look as follows:
Building and Installing the Module
The IDE uses an Ant build script to build and install your module. The build script is created for you
when you create the module project.
Installing the NetBeans Module
- In the Projects window, right-click the Additional Samples project and choose Install/Reload
in Target Platform.
The module is built and installed in the target IDE or Platform. The target IDE or Platform opens so that you
can try out your new module. The default target IDE or Platform is the
installation used by the current instance of the development IDE. Note that when you run your module, you will be using
a temporary test user directory, not the development IDE's user directory.
Using the NetBeans Module
- Choose File > New Project (Ctrl-Shift-N).
The New Project wizard opens and displays
the new project sample:
- Select the new project sample and click Next. The wizard panel appears:
Type a name in the project name field.
- Click Finish. The IDE opens and
displays the newly created project sample.
Creating a Shareable Module Binary
- In the Projects window, right-click the Additional Samples project and choose Create NBM.
The NBM file is created and you can view it in the Files window (Ctrl-2):
- Make it available to others via, for example, e-mail.
Next Steps
For more information about creating and developing NetBeans Modules, see the following resources:
Versioning
Version
|
Date
|
Changes
|
1
|
9 July 2005
|
Initial version
|
2
|
10 July 2005
|
- Added the org.netbeans.modules.java.examples.J2SESampleProjectIterator wizard
as an alternative -- less strict than the web wizard.
- Expanded the Ant script that zips the project sample, so that it now excludes
build, dist, and nbproject/private folders.
|
3
|
23 August 2005
|
- Completely rewrote the tutorial, because of the Project Template wizard.
- Questions:
- What's the Category drop-down for? Select the category
in the New Project wizard where the sample will be registered, but
not implemented yet.
- Layer file indicates that no Bundle file exists, but it does.
- To do:
- Add details on each of the created files (currently there's only a sentence,
this should be expanded).
- Explain relationship between generated files and resulting project template wizard.
- Add some post-processing customization steps (e.g., how to put the sample in a
different category in the New Project wizard).
- Add introductory sentences to each section.
- Info about XML layer file to be added.
|
4
|
1 October 2005
|
- Worked through the tutorial with today's build and tweaked here and there.
- To do:
- Add details on each of the created files (currently there's only a sentence,
this should be expanded).
- Explain relationship between generated files and resulting project template wizard.
- Add some post-processing customization steps (e.g., how to put the sample in a
different category in the New Project wizard).
- Add introductory sentences to each section.
- Info about XML layer file to be added.
|