Configuring the Classpath


When you create a project, the IDE sets up a default classpath for you based on the project template you are using. If you have other things to add to the classpath, you can do so through the Libraries node of the project.

In fact, the IDE distinguishes among several types of classpaths, depending on project type, such as compilation classpath, test compilation classpath, running classpath, and test running classpath. The compilation classpath typically serves as a base for the other classpaths (for example, other classpaths inherit what is in the compilation classpath).

To add an item to the compilation classpath (and, thus, the other classpaths as well), right-click the project's Libraries node and choose Add JAR/Folder (see Figure 2-2).

Figure 2-2. Projects window, adding a JAR file to the classpath


When you right-click the Libraries node, you also can choose Add Project or Add Library. When you add a project, you add the project's output (such as a JAR file) to the classpath.

If you choose Add Library, you can add one of the "libraries" recognized by the IDE's Library Manager. In the Library Manager, libraries are essentially just a convenient grouping of one or more JAR files, sources, and/or Javadoc documentation. Designating libraries in the Library Manager is useful for several IDE features. For example, designating a JAR file and its sources as a library ensures that you can step through that JAR file's code when debugging.

You can manage existing libraries and designate new ones in the Library Manager, which you can open by choosing Tools | Library Manager.


You can edit other classpaths in the Properties dialog box for a project. To open the Project Properties dialog box, right-click the project's node in the Projects window and choose Properties. In the dialog box, click the Libraries node and use the customizer in the right panel to specify the different classpaths (see Figure 2-3).

Figure 2-3. Project Properties dialog box, Libraries page




NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net