NetBeans-SCSNI

2.1-Describe the characteristics and uses of a free-form project.

About Free-Form Java Projects

The IDE also contains free-form project templates for Java and web applications. Free-form projects do not produce an Ant script or hold project metadata in another form. Instead, these projects rely on your existing Ant script to provide instructions for handling your project source.
The full distribution of the IDE contains the following free-form templates:
  Java Free-Form Project. A free-form project containing one or more Java source roots.
  Web Free-Form Project. A free-form project containing a web application and optionally other Java source roots.

Source Folders
Free-form Java projects can contain multiple source folders. The classpath relationships and handling instructions for your source directories must be handled in your Ant script.

Project Settings
In the project's properties, you declare the source folders, classpath, and output files for your project. Each source root can have a unique classpath and output file. These settings do not affect the actual contents or classpath of your application. The settings only tell the IDE how to handle the code. For example, the classpath settings tell the IDE which classes to make available for code completion.

IDE Commands and Ant Targets

In free-form projects, the IDE relies on your Ant script to provide targets for all IDE actions, such as running, debugging, and generating Javadoc. If your Ant script does not contain targets for these commands, the commands are disabled.

You can write debug targets in your Ant script or in a supplementary Ant script. You can also add a shortcut to any of your Ant script's targets to the contextual menu of your project's node in the Projects window.

Declaring the Classpath in a Free-Form Project

In a free form project , all classpath relationships between your source folders are handled by your Ant script. In order for the IDE to know which classes to include in code completion and refactoring, you have to declare the classpath in the project settings.

You first declare the classpath in the New Project wizard when creating the project. You can edit all classpath declarations for an existing project in the Project Properties dialog box.

Declaring the classpath in the Project Properties dialog box does not change the actual compilation or runtime classpath of the source folders. The project's classpath declaration must exactly match the classpath used by your Ant script.

To declare the classpath for a project:

  1. Build the project so that all of the project's build outputs (JAR files and WAR files) exist on your computer.
  2. In the Projects window, right-click the project node and choose Properties.
  3. Click Classpath in the right panel of the Project Properties dialog box.
  4. Declare the classpath for the project.
  • To set a common classpath for all source folders, unselect the Separate Classpath for Each Source Package Folder checkbox. Then add or remove classpath elements with the buttons on the right of the dialog box.
  • To set a separate classpath for each source folder, leave the Separate Classpath for Each Source Package Folder checkbox selected. Select a source folder in the drop-down list and add or remove classpath elements for the source folder.
  • To add the build output of source folder A to source folder B, select the source folder B in the drop-down list and click Add JAR/Folder. Then navigate to the output folder of source folder A and select its build output. You must have a separate classpath for each source package folder to set up relational classpath dependencies between source package folders.

If you have attached Javadoc and source files to a JAR file in the Library Manager, the IDE automatically adds the Javadoc and source files to the project when you register the JAR file on a project's classpath. You can step into classes and look up Javadoc pages for the classes without configuring anything else.

For a full guide to configuring free-form projects, see:

http://www.netbeans.org/kb/55/freeform-config.html


- Wagner R. Santos- 20/10/2008