The Wayback Machine - https://web.archive.org/all/20050622234158/http://www.netbeans.org:80/kb/41/transition.html

Transitioning from NetBeans IDE 3.6 to 4.1

NetBeans IDE 4.0 was a major step forward in the life of NetBeans IDE. The introduction of the new Ant-based project system gives you tighter classpath management, more versatile build and run options, and the tightest integration to Ant of any IDE on the market. It also presented a major change in work flow for users who were used to the NetBeans IDE 3.6 "mounting" system. If you are such a user and did not want to switch to 4.0 but are now interested in 4.1 (whether because of project system refinements or the new J2EE support provided), this guide should help your transition.

Contents


Ant-Based Projects System

NetBeans IDE 4.1 has an innovative project system based directly on Apache Ant. This project system uses an Ant build script to compile, run, execute, and test your applications and to store all metadata about the project.

You don't have to be an Ant expert or even know how to use Ant to work with your projects in NetBeans IDE. The IDE provides a set of standard project templates that contain everything you need to develop your applications. You can configure all your basic compilation and runtime options in the project's graphical interface.

If you are an advanced Ant user, you can use the full power of Ant to customize your build process. You can extend a standard project's build script by overwriting its Ant targets. The IDE also contains a set of free-form project templates that let you control your project's execution and compilation with your own Ant script.

Back to top

Comparison with NetBeans IDE 3.6

In NetBeans IDE 4.1, you create a standard project for each output that you want to create (in most cases, a JAR file) and set up directional classpath dependencies between them. These outputs can be built from multiple source package roots (whereas in NetBeans IDE 4.0, it was possible to have only one source package root per project.) Within each project, you can have a separate classpath for compiling, running, and testing your application. If you use your own Ant script to build and execute your projects, you can create a free-form project in which you can have multiple outputs.

The following table looks at some of the most visible differences between NetBeans IDE 3.6 and 4.1:

NetBeans IDE 3.6 NetBeans IDE 4.1
Classpath
There is only one classpath for each project. The classpath is made up of everything mounted in the Filesystems window. Each standard project has one classpath per project, but you can configure different versions of the classpath for testing, running, and debugging. You can set the classpath for each source package folder in the Project Properties dialog box for the project.

The classpath for free-form projects is controlled by the Ant script and can therefore be more complex.

Accessing Files and Project Views
You have to mount every folder that you want to access. The Filesystems window just provides a folder-based view of the contents of your sources. You can add individual files to the Projects window. The Projects window provides a logical organization of your Java sources and web applications. Sources are displayed per package under the Source Packages node. The Files window shows you the physical layout of your project folder on the disk. You can access any location on your computer in the Favorites window.
Building an Output File
You create a JAR or WAR Recipe node in the Filesystems window and use the node's properties and contextual menu to generate a JAR or WAR file. A JAR file is built every time you build a standard J2SE project. A WAR file is built every time you build a web project. You set filter and compression options in the Build | Packaging page of the Project Properties dialog box. Standard projects build one output file per project.

In free-form projects, the production of output files is controlled by your Ant script.

Sharing Projects
You cannot share projects and project settings between developers. All of the project metadata is contained in the project folder, in the form of Ant scripts, Ant properties files, and a few XML files. You can put this metadata under version control and identify certain settings as specific to your installation only.
Configuring Settings
You configure all settings in the Options window. You manage execution, debugging, and compilation settings using service types that you assign to a project or individual files.

You set project-related settings, like classpath, compilation settings, and runtime arguments, in the Project Properties dialog box. You can further configure settings by editing a project's Ant script and Ant properties file.

You configure general IDE-wide settings, like syntax coloring, web browser settings, and system settings, in the Options window.

Web Applications
You have to mount every folder that you want to access. The Filesystems window just provides a folder-based view of the contents of your sources. You can add individual files to the Projects window. The JSP 1.2 and 2.0 specifications are supported and JSP files are not compiled by the IDE, but validated. Tomcat Server 5.5.7 is integrated with NetBeans. As with J2SE projects, web projects are developed using the new project system that is supported by Ant. Web projects can use sources from multiple folders, such as web classes outside WEB-INF/classes and libraries outside WEB-INF/lib. If a web project depends on a Java Class library, the library can be handled as a separate project. There is enhanced support for the JSP 2.0 specification, with wizards for tag handlers and tag files and code completion for tag library descriptors. JSP compilation is reintroduced, now handled by Ant. Tomcat Server 5.5.7 is integrated with NetBeans IDE 4.1.

Back to top

Standard Projects vs. Free-form Projects

The following table lists the major differences between standard projects and free-form projects in NetBeans IDE 4.1:

Standard Projects Free-Form Projects
The IDE uses a NetBeans-generated Ant build script to build, run, clean, test, and debug your application. The IDE uses targets in an existing Ant script to build, run, clean, test, and debug your application. If the Ant script does not contain targets for some of these functions, the functions are unavailable. You can write targets to implement these functions, either in your Ant script or in a secondary Ant script.
The project classpath is controlled by the settings you set in the Build | Compiling page of the Project Properties dialog box. Any changes are immediately registered in the IDE-generated Ant script. The project classpath is controlled by your Ant script. The classpath settings in the Java Sources Classpath page of the Project Properties dialog box only tell the IDE which classes to make available for code completion and refactoring. When you change the classpath settings in the Ant script, you have to update the settings in the project's properties.
The build process is customized by setting basic options in the Project Properties dialog box or by overwriting targets in the NetBeans-generated Ant script. All compilation and runtime options are set in the Ant build script.
The IDE builds one JAR file (for J2SE projects) or WAR file (for web projects) for the entire source folder. The IDE builds as many build products as are specified in the project's Ant script.

Back to top

Importing Source Code from NetBeans IDE 3.6

Because the NetBeans 4.x projects structure is so different from that of the previous IDE versions, automatic importing of NetBeans IDE 3.6 projects is not implemented. (Since in NetBeans 3.6 you have to mount a single folder numerous times in order to access all the necessary resources for an application, the IDE would not be able to tell which of the mount points was an actual source folder.)

To import the source code you were working on in version 3.6, create a new project for each JAR file or WAR file that needs to be created (or if you have your own Ant script, one free-form project for the entire application). For more information on importing source code into NetBeans IDE 4.1, see the following documents:


Back to top

Importing NetBeans IDE 3.6 Settings

Although your mounted folders and the settings associated with them cannot be imported from NetBeans IDE 3.6, many of your general IDE settings are imported when you first run NetBeans IDE 4.1. Settings from versions of the IDE before 3.6 are not importable.

The following settings are imported from NetBeans IDE 3.6:

Settings to be imported Location in IDE
Java and Source Editor Settings
Editor settings for all file types Tools > Options > Editing > Editor Settings > <mime-type> Editor
Source Editor annotation settings Tools > Options > Editing > Annotation Types
Printer settings Tools > Options > IDE Configuration > System > Print Settings
Indentation engine settings Tools > Options > Indentation Engines
General Java source settings Tools > Options > Editing > Java Sources
Tools > Options > Editing > Source Synchronization
Form Editor settings Tools > Options > Editing > Form Editor Settings
Internationalization settings Tools > Options > Editing > Internationalization
Template settings and custom templates Tools > Options > Source Creation and Management > Templates
Generation of getters and setters Tools > Options > Editing > Beans Property
System Settings
System settings like proxy information and preferred browser Tools > Options > System
General keyboard shortcuts Tools > Keyboard Shortcuts
Diff configuration Tools > Options > IDE Configuration > Server and External Tool Settings > Diff and Merge Types
External browser configuration Tools > Options > IDE Configuration > Server and External Tool Settings > Web Browsers in the IDE options dialog
HTTP server settings Window > Runtime > HTTP Server
Saved HTTP Monitor transactions Window > HTTP Monitor > Saved Records
Server Registry settings Window > Runtime > Server Registry
VCS Settings
General VCS settings
Tools > Options > Source Creation and Management > Version Control Settings
VCS Groups settings
Tools > Options > Source Creation and Management > Version Control Settings > VCS Groups Settings
Database Settings
Registered JDBC drivers Window > Runtime > Databases > Drivers
Database connections and module settings Tools > Options > IDE Configuration > Server and External Tool Settings > Database Explorer

Back to top

Common Project Tasks

The following table explains how to perform common project tasks in NetBeans 4.1:

To perform this task Follow these steps

Create a standard project from existing sources.

  1. Choose File > New Project (Ctrl-Shift-N).
  2. Select Web > Web Application with Existing Sources or General > Java Project with Existing Sources.
  3. Follow the rest of the directions in the wizard.

Create a free-form project from existing sources and Ant script.

  1. Choose File > New Project (Ctrl-Shift-N).
  2. Select Web > Web Application with Existing Ant Script or General > Java Project with Ant Script.
  3. Follow the rest of the directions in the wizard.

Add a JAR file to a standard project's classpath.

  1. In the Projects window, expand the project's node.
  2. Right-click the Libraries node, choose Add JAR/Folder, and then specify the JAR file that you want to add.

Set up compilation dependencies between projects.

  1. In the Projects window, expand the project's node.
  2. Right-click the Libraries node, choose Add Project, and then specify the JAR file that you want to add and select the project folder for the project that you want to add to the project's classpath.
    Note: For free-form projects, use the Add JAR/Folder command to add the output JAR files of the project to the classpath.

Add Javadoc documentation and source code to JAR files on the classpath.

  1. Choose Tools > Library Manager from the main window.
  2. If the JAR file is not already registered in the Library Manager, create a new empty library using the Add Library button.
  3. Select the library in the left panel of the Library Manager.
  4. In the Classpath tab, click Add JAR/Folder and specify the location of the JAR file containing the compiled class files. A library can contain multiple JAR files.
  5. Use the Sources and Javadoc tabs to add the folders or archive files containing the source code and documentation.
  6. Click OK to exit the Library Manager.
  7. If the JAR file is not already on the compilation classpath for your project, add it to the classpath as described above.

Set project main class, execution arguments, execution working directory, and VM arguments.

  1. In the Projects window, right-click the project node and choose Properties.
  2. Click Running Project and enter the appropriate information.
Customize build steps.
  1. In the Files window, expand your project folder and open nbproject/build-impl.xml and nbproject/project.properties. build-impl.xml contains all of the processing instructions for your project. Do not write to this file, as any changes to it will be overwritten by the IDE.
  2. Find the build targets and properties that control the build step you want to change. Each of the major build targets has a pre and post target that you can override to add instructions before and after the target is executed.
  3. Double-click build.xml in your project folder and override any targets from build-impl.xml.
  4. Edit any of the build properties in project.properties. If you are sharing the project metadata and do not want to share one of your settings, override it in nbproject/private/private.properties instead.

Set the build output folder.

  1. In the Files window, expand the nbproject node in your project folder.
  2. Double-click project.properties to open it in the Source Editor.
  3. Set the build output folder in the build.dir property. If you set a build output folder outside of the project folder, it is not accessible in the Files window.
    NOTE: The build output folder is deleted every time you clean the project. You should therefore not set the build output folder to your source folder.

Back to top
 
 

Related Documents

A short guide to getting your existing Java desktop applications into NetBeans IDE 4.1.
A short guide to getting your existing web applications into NetBeans IDE 4.1.
A short guide to getting your existing enterprise applications and EJB modules into NetBeans IDE 4.1.
A short guide to getting your existing J2ME platform source code into NetBeans IDE 4.1.
A short guide to getting your existing web applications into NetBeans IDE 4.1.
Complete list of documentation for NetBeans IDE 4.1.