5.1 About Creating Java Projects

A project is a group of source files and the settings with which you build, run, and debug those source files. In the IDE, all Java development has to take place within a project. For applications that involve large code bases, it is often advantageous to split your application source code into several projects

The IDE includes several project templates designed to support different types of development including web applications, general Java applications, and so forth. The IDE's set of standard project templates automatically generate an Ant script and properties. The IDE also contains free-form project templates that you can use to base a project on an existing Ant script. In addition to Ant, the IDE also supports Maven, an open source build management tool. Maven uses a project object model (POM) that describes a set of standards that all projects using Maven follow allowing for consistency between projects. You can easily create a Maven project by choosing a Maven project template and providing a few project details.

Note:

You do not need an in-depth understanding of Ant or Maven to work with the IDE as the provided set of standard project templates automatically generate an Ant script or Maven POM files based on the options you enter in the IDE.

When you finish creating a project, it opens in the IDE with its logical structure displayed in the Projects window and its file structure displayed in the Files window:

The Projects window is the main entry point to your project sources. It shows a logical view of important project contents such as Java packages and Web pages. You can right-click any project node to access a context menu of commands for building, running, and debugging the project, as well as opening the Project Properties dialog box. The Projects window can be opened by choosing Window > Projects.

The Files window shows a directory-based view of your projects, including files and folders that are not displayed in the Projects window. From the Files window, you can open and edit your project configuration files, such as the project's build script and properties file. You can also view build output like compiled classes, JAR files, WAR files, and generated Javadoc documentation. The Files window can be opened by choosing Window > Files.

Note:

If you need to access files and directories that are outside of your project directories, you can use the Favorites window. You open the Favorites window by choosing Window > Favorites. You add a folder or file to the Favorites window by right-clicking in the Favorites window and choosing Add to Favorites.

5.2 Using Java Project Templates

You can facilitate creating a Java application by using one of the available templates provided by the IDE. For each type of Java application, the IDE provides two types of project templates:

Standard templates. Templates in which the IDE controls all source and classpath settings, compilation, running, and debugging.

5.2.1 Standard Project Templates

With standard project templates, the IDE controls all aspects of how your application is built, run, and debugged. You set a project's source folder, classpath, and other project settings when creating the project and in the Project Properties dialog box. The IDE generates an Ant build script in which all of your settings are stored.

Module Project - An empty module with a layer.xml file and a Bundle.properties file. You use a module to implement the logic that integrates the library wrappers into the platform and provides a user interface for receiving user input.

Module Suite Project - A library wrapped in a module project and a Bundle.properties file. You use a library wrapper to put a library JAR file on a module's classpath and export some or all of the JAR file's packages from the module as public packages.

Library Wrapper Module Project - An empty module suite. You use a module suite to group and deploy a set of interdependent modules and library wrappers.

Depending on what modules you have installed, your IDE may contain additional templates. Consult the help for your additional modules for more information.

5.2.1.1 Source Folders

In standard projects, you can have multiple source folders and multiple JUnit test folders for each Java SE, web, and EJB project.

Right-click the Source Packages node of a project and choose Properties to add or remove source folders. A single source folder cannot, however, be added to more than one project. If you need a source folder to be part of several projects, you should create a separate project for the source folder and add it to the classpath of each of your projects.

5.2.1.2 Project Settings

When you create a project from a standard project template, the IDE generates an Ant script that controls all aspects of program compilation, execution, and debugging.

Right-click a project node in the Projects window and choose Properties to set basic project settings in the Project Properties dialog box. All changes are immediately registered in the project's Ant script. You can also set more complex options by editing the project's Ant script and properties file directly.

5.2.1.3 Switching a Java SE Project to a JavaFX Deployment Model

If you have an existing standard Java SE project and you want to take advantage of the JavaFX deployment model, you can quickly switch your current project by choosing Properties from the project's context menu, selecting the Deployment category, and clicking Switch Project to JavFX Deployment Model. This feature saves you the time consuming effort of creating a new JavaFX application and manually copying over the project artifacts to the new project and resetting options, removing the main class, and so on.

Instead of a main class, JavaFX projects use an extension to the Application class. When you switch the project, the IDE creates a project_nameFX.java class and automatically adds it to the Source Packages folder of your SE project. You then have the option of using JavaFX customizations, such as specifying a JavaFX runtime version or adding custom manifest entries through the Project Properties dialog box.

Note:

Be aware that once a Java SE project has been switched to a JavaFX deployment model, it cannot be automatically reverted.

5.2.1.4 Adding a JavaFX Class to a Java SE Project

You can add a JavaFX class to a Java SE project without having to manually add a JavaFX runtime dependency. This feature is particularly advantageous for making a Java class library project usable for JavaFX development. When you select the Keep JavaFX RT artifacts on Compile Classpath if not present by default option from the Deployment category of the Project Properties dialog box, the IDE automatically updates the jfxrt.jar file dependency. If you later change the project platform, the dependency is corrected for you.

5.2.1.5 Project Folders

Each standard project has a project folder where the IDE stores the Ant script, project metadata, and output folders. In projects with existing sources, you can place the project source directories in the same location as the project folder or in a separate location. In empty projects, the source root is always in the same location as the project directory.

Table 5-1 Standard Project Folder Contents

Item

Description

build.xml

The build script called by the IDE. This build script only contains an import statement that imports targets from nbproject/build-impl.xml. Use the build.xml to override targets from build-impl.xml or to create new targets.

nbproject

The directory that contains the project Ant script and other metadata.This directory contains:

build-impl.xml. The IDE-generated Ant script. You should never edit build-impl.xml directly. Always override its targets in build.xml.

project.properties. Ant properties used by the IDE to configure the Ant script. Although you can edit this file manually, you generally do not have to, as it is automatically updated by the IDE when you configure the project's properties.

project.xml and genfiles.properties. IDE-generated metadata files. Although you can edit project.xml manually, for standard projects it is generally not necessary. Never edit genfiles.properties.

nbproject/private

The directory that holds properties that are defined for you only. If you are sharing the project over VCS, any properties you define in private.properties are not checked in with other project metadata and are applied only to your installation of the IDE.

5.2.2 Free-Form Templates

With free-form project templates, the IDE relies on your existing Ant script for instructions on how to compile, run, and debug your applications. The settings you configure in the New Project wizard when creating a project as well as in the Project Properties dialog box are used to tell the IDE how your Ant script manages your source code and must be consistent with the settings in your Ant script.

For example, all classpath elements are handled by your Ant script. When you declare the classpath for a free-form project, you are only telling the IDE which classes to make available for code completion and refactoring. These settings do not affect the actual classpath used when compiling or running your source code.

Free-form projects can contain as many source folders as your Ant script is configured to handle. If your Ant script does not contain targets for all IDE actions, like debugging and running your project, you can easily write Ant targets for these actions.

The standard distribution of the IDE contains the following free-form Java project templates:

Java Free-Form Project. A free-form project containing one or more Java source roots.

5.2.2.1 Source Folders

5.2.2.2 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.

5.2.2.3 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.

5.2.2.3.1 Creating a Target to Compile a Single File

If you want to be able to select files in the IDE and compile them individually, you need an Ant target for the Compile File command. The IDE offers to generate a target the first time you choose the command. The generated target looks something like this:

In the generated target, you need to specify the directory where to put the compiled class or classes. You can do so by specifying a value for the build.classes.dir property in the generated target. For example, you might add the following line to the line above the <target name="compile-selected-files-in-src"> entry:

<property name="build.classes.dir" value="build"/>

Alternatively, you can replace the value of the provided build.classes.dir or rewrite the target entirely.

The value of the includes parameter is the value of the generated files property. The IDE uses this property to store the name of the currently selected file (or files).

Note:

You can configure multiple compile.single actions to overload the F9 shortcut and menu command with different functionality depending on what file is selected. For example, you could set up a separate compile-selected-files target for JUnit test classes, then map compile.single to that target for all sources in JUnit test directories. Or you could change the pattern to \.xml$ and map F9 to a Validate XML target for all XML files.

5.2.2.3.2 Writing a Target for the Apply Code Changes Command

The Apply Code Changes command allows you to make changes to your code during a debugging session and continue debugging with the changed code without restarting your program. The IDE contains a nbjpdareload task that you can use to write a target for the Apply Code Changes command.

Since you can only run the Fix command on one file at a time, you set <arity> to <one-file-only>.

You have to pass the full path to the .java file to the javac task and the full path to the .class file to the nbjpdareload task. You therefore set the <format> to rel-path-noext, then append .class or .java in the debug-fix target as necessary.

5.2.3 Creating Standard Projects

You can facilitate creating a Java application by using one of the available templates provided by the IDE.

To create a Java project:

Choose File > New Project (Ctrl+Shift+N).

Select the appropriate template for your project.

Follow the steps in the remainder of the application wizard.

Once you create your project, you can configure the classpath and add a JAR file, library, or an IDE project to the classpath as needed. Set your project as the main project to build it and then run it. If necessary, set the main class and any arguments for your project prior to running it. Afterwards, you can debug your project by setting breakpoints or watches and running the IDE's debugging tool.

Note:

Maven uses repositories that contain build artifacts and project dependencies. To create a Maven project, you need to configure Maven settings at both the IDE level and at the project level. For information on creating a Maven project, see Section 7.12, "Working with Maven in the IDE."

5.2.3.1 Managing the Classpath

Adding a group of class files to a project's classpath tells the IDE which classes the project should have access to during compilation and execution. The IDE also uses classpath settings to enable code completion, automatic highlighting of compilation errors, and refactoring.

Source roots must only exist in a single project and cannot be shared with other projects, regardless of whether they are opened or not. If you have to use a library in several projects, create a special project within which to store it.

5.2.3.1.1 Classpath and Standard Projects

For standard projects, the IDE maintains separate classpaths for compiling and running your project, as well as compiling and running unit tests. The IDE automatically adds everything on your project's compilation classpath to the project's runtime classpath. Also the project's compiled test files and everything on the tests' compilation classpath are added to the test runtime classpath.

Whenever you build a standard project for which a main class is specified, the IDE automatically copies any JAR files on the project's classpath to the dist/lib folder. The IDE also adds each of the JAR files to the Class-Path element in the application JAR's manifest.mf file. This simplifies running the application outside the IDE. For more information, see Section 7.9, "Preparing a JAR File for Deployment Outside the IDE."

In the Project Properties dialog box, add the necessary elements to the project's compilation classpath by clicking the appropriate button. You can add any of the following:

Project. The JAR file or WAR file produced by another project, as well as the associated source files and Javadoc documentation.

Library. A collection of JAR files or folders with compiled classes, which can optionally have associated source files and Javadoc documentation.

Note:

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.

JAR/Folder. A JAR file or folder that contains compiled classes.

(Optional) In web applications, click the Deploy checkbox if you do not want to package an element in the web application. By default, all classpath elements are included in the web application.

(Optional) Click the Build Projects on Classpath checkbox if you do not want to rebuild all projects on the classpath whenever you build the current project. By default, all projects on the classpath and, in web applications, projects listed in the Packaging page, are rebuilt when you build the current project.

(Optional) Click the Move Up and Move Down buttons to alter the classpath priority.

(Optional) Click the Run, Compile Tests, or Run Tests tabs to make any changes to the these classpaths.

5.2.3.1.2 Classpath and Free-form Projects

In free-form projects, your Ant script handles the classpath for all of your source folders. The classpath settings for free-form projects only tell the IDE what classes to make available for code completion and refactoring. To change a free-form project's actual compilation or runtime classpath you must edit your build.xml file directly. For information on setting runtime arguments, see Section 9.6, "Setting the Main Class and Runtime Arguments."

5.2.3.1.3 Adding Annotation Processors to the Classpath

In addition to other libraries, you can add annotation processors to the classpath or the processor path of your project. The annotation processors are specified as either a library, a JAR file, or another NetBeans IDE project. You can add annotation processors on the following tabs: Compile and Processor. Additionally, you can specify the FQN (fully qualified name) of the annotation processor on the Compile tab.

To add an annotation processor to the classpath:

Right-click the project node and choose Properties.

Select the Libraries category in the Project Properties window.

Select one of the following tabs in the Libraries panel and add the project, library or JAR that contains the annotation processor to the project's classpath.

Compile tab. When an annotation processor is packaged together with its annotations as a single JAR file, specify this JAR file on the Compile tab. In this case, there is no need to add it to the Processor tab. The resources added on the Compile tab correspond to the –classpath option of the Java compiler.

Processor tab. When an annotation processor and its annotations are packaged into separate JAR files, add the JAR file with the processor on the Processor tab and the JAR file with the annotations on the Compile tab. The resources added on the Processor tab correspond to the -processor path option of the Java compiler.

Select the Compiling node under the Build category and select Enable Annotation Processing and Enable Annotation Processing in Editor.

Click Add and type the fully-qualified name of the annotation processor in the Add Annotation Processor dialog box.

5.2.3.2 Creating Dependencies Between Projects

When creating Java applications you typically set up a single main project, which contains both the project main class and any required projects. Whenever you create separate standard project for each of a project's source roots, you have to set up the classpath dependencies between the main project and the required projects. A required project is a project that has been added to another project's classpath.

For standard projects that have a main class specified, the IDE automatically copies any JAR files on the project's classpath to the dist/lib folder when you build the project. The IDE also adds each of the JAR files to the Class-Path element in the application JAR's manifest.mf file. This simplifies running the application outside the IDE. For more information, see Section 7.9, "Preparing a JAR File for Deployment Outside the IDE."

Whenever you clean and build a project, the IDE also cleans and builds its required projects. The required project's attached Javadoc and source code are also made available to the project that you are building. For information on adding Javadoc, see Section 5.7.1, "How to Add a Javadoc to a Project."

If you want to add a free-form project to the classpath of a standard project, you have to declare all of the JAR files that are produced when the free-form project is built. Right-click the free-form project's node in the Projects window and choose Properties. Then specify those JAR files in the Output page of the dialog box.

To configure project dependencies:

In the Projects window, expand the node of the project to which you want to add a dependent project.

Right-click the Libraries node and choose Add Project.

Select the directory containing the project whose JAR files you want to add to the classpath. When you select the project directory, the project name and project JAR files are displayed in the dialog's right pane.

5.2.3.3 Editing IDE-Generated Ant Scripts

If you are working with a standard project and want to set more project options than are available in the Project Properties dialog box, you can edit the project's Ant script and Ant properties. The Ant targets and properties are defined in the following files in your project folder:

nbproject/build-impl.xml. The Ant script that contains all of the instructions for building, running, and debugging the project. Never edit this file. However, you can open it to examine the Ant targets that are available to be overridden.

build.xml. The main Ant script for the project. The IDE calls targets in this Ant script whenever you run IDE commands. build.xml contains a single import statement that imports targets from build-impl.xml. In build.xml, you can override any of the targets from build-impl.xml or write new targets.

nbproject/project.properties. The Ant properties file that contains important information about your project, such as the location of your source and output folders. You can override the properties in this file.

nbproject/private/private.properties. The Ant properties file that contains properties specific to your installation of the IDE. For example, if you are sharing the project over VCS, any properties you set in private.properties are not checked into the repository. You can copy a property from project.properties into private.properties and give the property different definitions in each file. The definitions in private.properties take precedence over those in project.properties.

Note:

In a free-form project, there is no build-impl.xml. The IDE directly calls targets in the project's Ant script.

5.2.3.4 Customizing the IDE-Generated Ant Script

You can edit the Ant scripts generated for standard projects to fine tune the way your project is built and run.

To override a target from an IDE-generated build script:

Copy the target from build-impl.xml or suite.xml to build.xml and make any changes to the target.

Note:

You might need to disable the Compile on Save option in project properties, because when enabled it causes some commands to skip calling the ant targets. To disable the Compile on Save option, right-click your project in the Projects window, select Properties, and clear the Compile on Same checkbox in the Compiling category.

To add instructions to be processed before or after an Ant target is run:

Override the -pre or -post target for the target.

For example, to insert an obfuscator after compilation, type the following in build.xml:

Optionally, add the new target to the dependencies of any of the IDE's existing targets. Override the existing target in build.xml then add the new target to the existing target's depends property.

For example, the following adds the new-target target to the run target's dependencies:

<target name="run" depends="new-target,init,compile"/>

Copy the dependencies exactly as they exist in build-impl.xml or suite.xml. Notice that you do not have to copy the body of the run target into build.xml.

Note:

The output folder is deleted every time you clean your project. Therefore, never set the output folder to the same location as your source folder without first configuring the clean target to not delete the output folder.

5.2.3.5.1 JavaFX Application and JavaFX FXML Applications

In a JavaFX Application without FXML, graphic layout and actions are both defined in Java classes. By default, both are defined in the main Application class.

In a JavaFX FXML application, graphic layout is defined in an FXML file and actions are defined in a controller Java class. The controller class implements the interface javafx.fxml.Initializable.

5.2.3.5.2 JavaFX Preloaders

A preloader is a small application that is started before the main application to customize the startup experience. You can create JavaFX preloaders either by running the New JavaFX Preloader wizard or by selecting Create Custom Preloader in the New JavaFX Application wizard.

5.2.3.5.3 Editing JavaFX Applications

Edit FXML files in one of two ways, depending on whether you have SceneBuilder installed:

If SceneBuilder is installed, go to the Projects window and either double-click the FXML file's node or right-click the FXML file's node and select Open. SceneBuilder opens automatically, focused on that FXML file. For information about installing and using SceneBuilder, see the JavaFX SceneBuilder documentation at http://docs.oracle.com/javafx/index.html.

If SceneBuilder is not installed, edit the FXML file as you edit any XML document in the IDE. If SceneBuilder is installed, you can choose to use the IDE's XML editor instead by right-clicking the FXML file's node and selecting Edit. For more information, see Section 17.2, "Creating and Editing XML Documents."

5.2.3.5.4 Building and Running JavaFX Applications

Build and run a JavaFX application as you build and run a standard Java application, with the difference that you can configure a JavaFX project to run in the following ways:

In Browser. The IDE embeds the application in a browser, using an HTML page that calls a JNLP page. The IDE can generate the HTML page or you can use your own web page. If you run the application from the IDE, the IDE opens a browser page that points to the HTML page on your local file system.

To set how a JavaFX application is run, open the Project Properties and go to the Run category. To open Project Properties, right-click the project's node in the Projects window and select Properties from the context menu. For more information on packaging a JavaFX application, see the chapter Packaging Basics in the JavaFX Documentation at:

5.2.3.5.5 Debugging JavaFX Applications

Debug JavaFX applications as you would debug Java applications. In addition, you can use the Java GUI visual debugger with JavaFX applications. For more information on JavaFX, see the JavaFX 2 documentation at http://docs.oracle.com/javafx/.

5.2.4 Creating Free-Form Projects

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.

5.2.4.1 Source Folders

5.2.4.2 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.

5.2.4.3 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.

5.2.4.4 Adding a Source Directory to a Free-Form Project

Free-form projects can contain multiple source directories, as long as the project's Ant script contains instructions on handling those source directories. To make project sources available to Ant, you need to specify the classpath for the project sources. If you have any custom tasks, you also need to add these tasks to Ant's classpath.

To add a source directory to a free-form project:

Build the project so that all of the project's build outputs (JAR files and WAR files) exist on your computer.

In the Projects window, right-click the project node and choose Properties.

Click Sources in the right panel of the Project Properties dialog box and add the source folder.

Click Classpath in the right panel of the Project Properties dialog box and set the classpath for the source directory.

You do this because by default the IDE ignores your environment's CLASSPATH variable whenever it runs Ant.

Note:

The classpath variable you set in the Project Properties dialog box does not affect the actual classpath of the project, which is specified in the Ant script. Declaring the classpath in the Project Properties dialog box does not change the actual compilation or runtime classpath of the source folders. However, the project classpath variable must match the classpath used by your Ant script in order to provide the correct information for code completion, error highlighting, and refactoring commands. You have to set an explicit classpath in your build scripts because the IDE ignores your environment's CLASSPATH variable whenever it runs Ant. If you change the classpath of one, you must change the class path of the other.

Click Output in the right panel of the Project Properties dialog box and specify the source folder's build output.

Click OK.

Specifying the Classpath for Custom Tasks

In free-form projects, you can call up and run custom Ant tasks in your build script. For your Ant script to use customs tasks, you must include the tasks in the Ant script's classpath. For example, you may add a task to your build script to format your code with Jalopy. In order to do this, however, you have to add the Jalopy JAR file to Ant's classpath.

You can add custom tasks to Ant's classpath within the IDE by doing either of the following:

Providing an explicit classpath to the tasks in your build script. This is the recommended method for specifying the location of JAR files that contain custom tasks used by your Ant script, as it ensures that your build scripts will be fully portable. You can write your tasks and include instructions to compile them and produce a JAR file in the build file. To use these tasks, include the long form of taskdef, which includes a classpath. Here is a simple example of such a task:

The advantage of this method is that no special preparation is needed to begin using the script. The script is entirely self-contained and portable. This method also makes it easier to develop your tasks within the IDE, as the script compiles them for you automatically.

To make your build scripts even more robust, use a property instead of a hard-coded location to specify the classpath to your tasks. You can store the property in the build script itself or in a separate ant.properties file. You can then change the classpath setting throughout your script by simply changing the value of the specified property.

Configuring the Ant Classpath property in the Options window. If you cannot declare a classpath in your build script, or you are using third-party build scripts which you cannot alter, you can add tasks to Ant's classpath in the IDE in the Options window.

Note:

If you modify the Ant classpath in the Options window, the task is on Ant's classpath for all projects when you run Ant in the IDE.

5.2.4.5 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:

Build the project so that all of the project's build outputs (JAR files and WAR files) exist on your computer.

In the Projects window, right-click the project node and choose Properties.

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 Ant 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.

5.2.4.6 Mapping an Ant Target to an IDE Command

In a free-form project, IDE commands must be mapped to targets in your Ant script. These mappings are recorded in the project.xml file in your project folder.

There are three ways to map an IDE command to a target in an Ant script:

By adjusting the settings in the Build and Run page of a project's Project Properties dialog box

You can use the Project Properties dialog box to add a shortcut to any Ant target to the project node's context menu. For example, if you have several runnable classes that you have to run often, you can write targets to run these classes and then run them using the links. Right-click the project node, choose Properties, and register the shortcuts in the Build and Run page of the dialog box.

By having the IDE generate a target for you and then customizing this target to your needs. This works for the Debug Project and Compile File commands. The IDE offers to generate these targets the first time you run those commands in the project.

By manually editing the project's project.xml file.

Mappings are recorded in the project.xml file automatically in the following cases:

When you specify a target for a command in the Build and Run Actions page of the New Project wizard.

When you specify a target for a command in the Build and Run panel of the Project Properties dialog box for a project.

When you create a mapping for a command after having chosen the command from the Build menu or Run menu and having been prompted to create the mapping.

When you have had the IDE generate a target. (The IDE offers to generate a target for the Debug Project and Compile File commands the first time you choose these commands in a free-form project.)

To map commands for a project:

In the Projects window, right-click the project node and choose Properties.

Click Build and Run in the right panel of the Project Properties dialog box.

Note:

The Project Properties dialog box is the main tool for configuring free-form projects in the IDE.

If your Ant script uses an import statement to import targets from another Ant script, the targets only appear if the <import> target specifies the full path to the secondary Ant script. If the <import> target uses a property to reference the secondary Ant script, the targets do not show up in the drop-down lists. In this case, you have to type the name of the projects in the drop-down list for the command.

Use the Custom Menu Items list to add shortcuts to Ant targets to the project's contextual menu.

Each IDE project has a project.xml file that contains important metadata about your project's contents, the location of the project's Ant script, which targets to run for IDE commands, and other information. If you want to map commands that work on the presently selected files in the IDE, or if you want to map a command to a target in a separate Ant script, you have to edit the project.xml file by hand.

To map IDE commands in project.xml:

In the Files window, expand the node for your project folder and expand the nbproject folder.

Double-click project.xml to open it in the Source Editor.

Enter the following in <ide-actions>:

<action name="action_name">
<target>target_name</target>
</action>

Note:

The <ide-actions> element holds the mappings for IDE commands. You enter an action element with the name for any of the standard IDE actions and define the script and target to which you want to map the command.

If you want to map an action to a target in a separate Ant script, add the following before the <target> declaration:

debug.test.single. Run the test file for the currently selected file in the debugger.

debug. Debug project.

debug.single. Compile the currently selected file.

debug.fix. Run the Apply Code Changes command on the currently selected file.

debug.stepinto. Execute one line of the project main class in the debugger and pause.

profile.test.single. Profile the JUnit test for the selected file.

profile. Run project in the profiler.

profile.single. Profile the selected file.

javadoc. Generate Javadoc for project.

Note that actions that run on the currently selected files in the IDE require additional configuration in project.xml.

If you also want the command to appear in the project's contextual menu, enter the following in <context-menu>:

<ide-action name="action_name"/>

For example, the following maps the Debug Project to the debug-nb target of the project's Ant script:

<action name="debug">
<target>debug-nb</target>
</action>

The Ant targets for NetBeans IDE commands do not have to live in the same Ant script that you use to build and run the project. This is useful for users who cannot alter their Ant script. The following maps the Debug Project to the debug-nb target in a separate Ant script:

project.xml also has a context-menu element that controls the contents of a project node's contextual menu. If you manually add an action that is run on the project, make sure you register the action name in <context-menu> as well. If you use the Project Properties dialog box to configure a standard project command, the IDE automatically adds the command to the project's contextual menu.

5.2.4.7 Debugging Free-Form Projects

Similar to commands for compiling and running, debugging commands rely on various information, such as the location of your sources, the location of the compiled classes and other items on the classpath, and name of the project's main class.

In free-form projects, the IDE is not aware of any of these things. When you run a command in the IDE (such as Build), the IDE simply calls a target in your build script and lets the script handle the command. Therefore, for debugging to work, you also have to have a build script target for debugging. The IDE provides some custom Ant tasks to work with the debugger and also can generate a basic debug target, which attempts to fill in important details based on other targets in your script.

5.2.4.8 Storing IDE Targets in a Separate Ant Script

When using a free-form project, you sometimes have to write Ant targets for IDE actions. For example, you have to write an Ant target to run a program in the debugger or to compile the currently selected file in the IDE.

If you are not able to write these IDE targets in your project's Ant script, you can set the IDE to read these targets from a separate Ant script.

To map an IDE command to an Ant target in a separate Ant script:

Write the target in a separate Ant script.

In the Files window, expand your project folder node and the nbproject node.

5.2.4.9 Editing the project.xml File

Each IDE project has a project.xml file that includes important information about the project, such as:

Information about what the project's type (free-form or standard, Web application or standard Java SE application)

Mappings between project commands and targets in an Ant script

Information about the project's contents, classpath, and target Java platform. This information is used to visualize the project and enable code completion and refactoring.

For standard projects, there is usually no need to edit the project.xml file. In free-form projects, you often have to edit the project.xml file to hook up Ant targets to IDE commands and make other customizations.

5.2.4.9.1 Using Properties in the project.xml File

Like all XML files, you can define properties inside the XML file itself or store them in a separate .properties file. One way of keeping your project.xml page synchronized with the information in your Ant script is to import properties into project.xml from the same .properties file that is used by your Ant script.

Note:

All file paths in project.xml are by default relative to the project folder. If your Ant script is not located in the project folder, a classdir property that points to build/classes/ does not point to the same directory for the Ant script and for the project.xml file. (The project folder is the folder that contains your nbproject folder, not the nbproject folder itself. By default, the new free-form project wizard makes your Ant script's parent folder the project folder.)

You can solve this problem by defining properties for important paths (like project.dir) and using these properties to be more exact (for example, classdir=${project.dir}/build/classes).

To create and import properties in project.xml

In the Files window, double-click project.xml.

Enter the following between the <name> element and the <folders> element:

While you can add properties in any order, properties can only refer to other properties that have been defined previously in the file. The properties file path itself can also use property substitutions.

5.2.4.9.2 Validating the project.xml File

The IDE comes bundled with the XML schemas for free-form project.xml files and automatically validates a free-form project.xml file every time you edit and save it. You can view the XML schemas for the free-form project.xml file at the following locations:

5.2.5 Setting Up a Java Project Based on Existing Sources

For Java projects developed outside of NetBeans, you use an Existing Sources template in the New Project wizard to make a NetBeans project. In the wizard, you identify the location of the sources and specify a location for the NetBeans project metadata. You then use the Project Properties dialog box to configure the project.

To set up a NetBeans project for an existing Java application:

Choose File > New Project.

Choose Java > Java Project with Existing Sources. Click Next.

In the Name and Location page of the wizard, follow these steps:

Type a project name.

(Optional) Change the location of the project folder.

(Optional) Change the name of the build script used by the IDE. This might be desirable if there is already a build script called build.xml that is used to build the sources.

(Optional) Select the Use Dedicated Folder for Storing Libraries checkbox and specify the location for the libraries folder.

(Optional) Select the Set as Main Project checkbox. When you select this option, keyboard shortcuts for commands such as Clean and Build Main Project apply to this project.

When you add a folder containing source code, you must add the folder that contains the highest folder in your package tree. For example, for the com.mycompany.myapp.ui package, you add the folder that contains the com folder.

(Optional) In the Includes & Excludes page of the wizard, enter file name patterns for any files that should be included or excluded from the project. By default, all files in your source roots are included.

Click Finish.

5.3 Importing an Eclipse or JBuilder Project

You can import projects created in other IDEs, such as Eclipse or JBuilder, into the NetBeans IDE.

The functionality to import Eclipse projects is included into the standard NetBeans IDE distribution. For Eclipse projects, you can import a set of dependent projects from an Eclipse Workspace or import a single project ignoring dependencies.

For JBuilder projects, you must install the JBuilder Project Importer plugin from the NetBeans Update Center. For JBuilder projects, you can import a standard Java SE project with dependencies.

To import an Eclipse project into the NetBeans IDE:

Make sure that you have copy of the project that you want to import on your system.

Typically, this project would already be in an Eclipse workspace on your system.

Choose File > Import Project > Eclipse Project.

In the Workspace Location page of the wizard, select the Import Projects from Workspace radio button, and specify the workspace location. Click Next.

In the Projects to Import page, select the projects that you want to import.

Choose one of the following two options for storing the NetBeans project files:

Create imported NetBeans projects in a separate location. NetBeans uses the sources and libraries in the original Eclipse project folder but creates a separate folder to hold NetBeans project metadata and build outputs.

Note:

Typically, it is better to store NetBeans project data inside Eclipse project folders. In most cases, this means that the NetBeans project metadata will refer to sources and libraries with the same paths that are used by the Eclipse metadata. Therefore, checking out the project from a version control system on different machines should result in similar behavior both in NetBeans and Eclipse.

(Applicable when web applications are being imported only.) Click Next. In the Servers page, register any servers that your projects need with NetBeans IDE.

Click Finish.

After you have completed the wizard, the following dialog boxes might appear:

Import Issues. The Import Issues dialog box provides information about discrepancies between the project structure in Eclipse and in NetBeans and points out actions that you might need to take to correct the discrepancies.

You can copy the information from this dialog and paste it elsewhere for future reference.

In most cases, you use the project's Project Properties dialog box to resolve those issues. See Resolving Import Problems for a guide to resolving the most common problems.

Resolve Reference Problems. The Resolve Reference Problems dialog box alerts you to a specific reference problem with one of your project libraries. You can solve this problem after dismissing this dialog box by right-clicking the project's node and choosing Resolve Reference Problems.

Resolve Missing Server. The Resolve Missing Server dialog box alerts you that the project cannot find a necessary server. You can solve this problem after dismissing this dialog box by right-clicking the project's node and choosing Resolve Missing Server.

After you have completed the wizard and have closed any of the above informational dialog boxes, nodes for the projects will appear in the Projects window.

If there are references in your project metadata to servers or other resources that NetBeans cannot resolve, the node for the project will appear in red. You can resolve these references immediately by right-clicking the project node and choosing Resolve Reference Problems or Resolve Missing Server.

For other types of project configuration adjustments, you use the Project Properties dialog box. You open the Project Properties dialog box by right-clicking the project's node and choosing Properties.

After you have imported the project, you will find the following folder and files on your system:

build.xml file or nb-build.xml file. The main NetBeans build script for the project. You can customize this script according to the needs of your project. By default, this file is called build.xml. If such a file already exists in the project folder, the script is called nb-build.xml.

nbproject folder. Contains most of the NetBeans project metadata, including resources that are called by the main NetBeans build script. If you check this folder and the build.xml file or nb-build.xml into your version control system, other users will be able to open the project in NetBeans. This folder also contains the private folder, which contains data specific to your system. This folder should not be checked in to the version control system since its contents will vary between users. See Version Control Considerations below.

nbbuild folder. When you build or run your project in NetBeans, the project's sources are compiled into this folder.

nbdist folder. When you build your project in NetBeans, the project's distributable outputs are created and placed in this folder. Such outputs might be JAR files and WAR files.

Version Control Considerations

If the project is checked out of a version control system, the build (or nbbuild), dist (or nbdist), and the nbproject/private folders should not be checked into that version control system.

If the project is under the CVS, Subversion, or Mercurial version control systems, the appropriate "ignore" files are created or updated for these directories when the project is imported.

Note:

Though nbproject/private should be ignored, nbproject should be checked into the version control system. nbproject contains project metadata that enables others users to open the project in NetBeans without having to import the project first.

Building and Running an imported Project

Once you have the project imported into NetBeans, you can build and run the project. All artifacts created from NetBeans build and run commands are created in the build and dist folders. NetBeans does not over-write output created from Eclipse build actions. If the Eclipse project already has build and dist folders, the NetBeans project creates folders called nbbuild and nbdist and uses those for the build outputs.

The following are some of the build and run commands are available from the Run menu:

Run Project. Test runs the application in the IDE.

Clean and Build Project. Deletes the contents of the build (or nbbuild) and dist (or nbdist) folders and rebuilds all of the project's outputs. Uses the NetBeans build script. Similar to the Clean command in Eclipse.

The project importer features synchronization capabilities. If the classpath in the Eclipse has changed since you initially imported it, you can use the Resynchronize Eclipse Projects feature to update the classpath in the corresponding NetBeans project.

Project resynchronization is one-way from Eclipse projects to NetBeans projects. If you make changes to the project structure in NetBeans, those changes are not propagated to the Eclipse project with the resynchronization feature. If you intend to keep both Eclipse and NetBeans projects, use the Eclipse project as the "master" project.

The IDE also resynchronizes the projects automatically if the changes to the Eclipse configuration are unambiguous and do not require your input. This automatic resynchronization occurs shortly after you open the project. If the resynchronization requires your input, you need to manually resynchronize the project.

To manually resynchronize NetBeans projects with Eclipse projects:

Choose File > Import Project > Resynchronize Eclipse Projects.

Note:

When you resynchronize a project, the resynchronization is performed on all projects that you have imported from the workspace.

Resolving Import Problems

When you import a project into NetBeans, there might be some things that can not be automatically resolved in NetBeans IDE. For some of these problems, a menu item, such as Resolve Missing Server Problem, appears in the contextual menu for the project. Other problems can be resolved in the Project Properties dialog box for the imported project in NetBeans IDE.

Here is a list of common import problems and their solutions.

Problem Message

Solution

Resolve Missing Server Problem

Right-click the project node and choose Resolve Missing Server Problem. Then navigate to the file or folder that contains the server.

Resolve Reference Problem

Right-click the project's node and choose Resolve Reference Problem. Then navigate to the file or folder that contains the resource that is referred to from the project.

Eclipse platform for project ProjectName cannot be used. It is a JRE and the NetBeans project requires a JDK. NetBeans will use the default platform.

If you would like to change the platform that NetBeans uses for the project, choose Tools > Platforms and specify a different platform.

Eclipse project ProjectName claims to use JDK from the "{1}" directory. But this directory does not exist. NetBeans will use the default platform.

If you would like to change the platform that NetBeans uses for the project, choose Tools > Platforms and specify a different platform.

NetBeans does not support source includes/excludes per source root as Eclipse does. They were merged and it is recommended that you double check them in project's properties in Source panel.

In NetBeans, includes and excludes are declared in one place for the whole project. To check the includes and excludes in the NetBeans project, right-click the project's node and the Projects window and choose Properties. In the Project Properties dialog box, select the Sources tab and then click the Includes/Excludes button.

Import failed due to .... More details can be found in IDE's log file.

5.4 Setting the Main Project

When you develop a large application consisting of numerous source directories, it is common to split up your code into separate projects. Of these projects, one is typically the entry point for your application and contains the application's main class.

To tell the IDE which of your projects is the main entry point for your application, you set one project to be the main project. The IDE provides commands that act on the main project. For example, running the Build Main Project command builds both the main project and all of its required projects, thereby ensuring that you all of your compiled classes are up-to-date. Only one project can be the main project at any time.

After you set a project as the main project, the keyboard shortcuts for Run (F6), Build (F11) and Clean and Build (Shift+F11) apply to the main project regardless of which project is selected in the Projects window. Keyboard shortcuts for Debug and Profile also apply to the main project.

To make a project the main project:

Choose Run > Set Main Project from the main menu and select a project from the list of open projects.

Alternatively, you can right-click the project node in the Projects window and choose Set as Main Project.

5.5 Adding Multiple Sources Roots to a Project

You can add multiple sources roots to either standard or free-form projects that require them. However, never add the same source root to more than one project because this is not supported in the IDE.

In Standard projects, it is sometimes advantageous to add additional source roots to your project's classpath such as when the project uses sources stored in a separate resources folder. Because all source directories on a standard project's classpath form a single compilation unit, they are also packaged into the application's JAR when the project is built. In Standard projects, you add source roots to the classpath using the project wizard and properties dialog.

In free-form projects, each source root can be assigned to independent compilation units providing you maximum flexibility when structuring your applications. Free-form projects, however, require that you manage the classpath by editing your build.xml file directly. For more information, see Section 5.2.3.1, "Managing the Classpath."

Note:

For both standard and free-form projects, source roots must only exist in a single project and cannot be shared with other projects, regardless of whether they are opened or not. If you have to use a library in several projects, create a special project within which to store it.

If you want to add a library to multiple projects, you must create a special project within which to store the library's compiled source that you want to use.

5.6 Sharing a Library with Other Users

As the NetBeans IDE project system is Ant-based, NetBeans projects are generally portable between different users, whether or not they use the IDE. However, by default, the project build script's way of referring to libraries is dependent on factors specific to each user, particularly in the case of libraries defined in the Library Manager dialog box.

A potential inconvenience is that libraries are stored in a variety of locations, based on where they originate. Libraries that come with the IDE are stored in various different folders within the IDE's installation. Examples of these include the libraries for the Swing Layout Extensions, beans binding, and database drivers.

You can configure most standard Java SE, Web, and Enterprise projects in a way that makes it easy to share libraries with other users. You can specify a location for libraries on which the project relies. You can also specify how the libraries are referenced from your project.

These options make it easy for you to handle the following situations:

You create a project and need to make it available and buildable to other users, whether they use the IDE or not. They must be able to access the project through a version control checkout or by unpacking a ZIP file that you have provided them. Then they should be able to build the application without extra configuration.

You must start working on an existing project and adhere to a strict set of conventions concerning where project libraries are stored (and whether your build script accesses them with a relative reference or absolute reference). Other users on the team are not using NetBeans and have no plans to switch.

5.6.1 How to Share a Library

You can make a project's libraries sharable when you create the project in the New Project wizard. You can convert an existing project to be sharable in the Libraries tab of the Project Properties dialog box.

To make a general Java project's libraries sharable upon project creation:

Choose File > New Project.

In the Java category of the wizard, select one of the standard templates and click Next.

In the Name and Location page of the wizard, select the Use Dedicated Folder for Sharing Libraries checkbox.

In the Libraries field, select the location for the libraries to be stored.

If the libraries are already included in the IDE, those libraries are copied to the folder that you have designated.

To make a web or enterprise project's libraries sharable upon project creation:

Choose File > New Project.

Select one of the standard templates in the Web or Enterprise category and click Next.

In the Name and Location page of the wizard, select the Use Dedicated Folder for Sharing Libraries checkbox.

In the Libraries field, select the location for the libraries to be stored.

If the libraries are already included in the IDE, those libraries are copied to the folder that you have designated.

(Optional) On the Server and Settings page, select the Copy Server JAR Files to Libraries Folder radio button.

To make an existing project's libraries sharable:

Right-click the project's node and choose Properties.

In the Project Properties dialog box, select the Libraries node.

In the Libraries panel, click Browse to open the New Libraries Folder wizard.

In the Library Folder page of the wizard, enter a location for the libraries and click Next.

You can enter the location as a relative reference or an absolute reference.

In the Actions panel of the wizard, verify the selected action for each listed library. In most cases, the IDE detects the most appropriate action for that library.

The following actions are available:

Copy Library JAR Files to New Libraries Folder. Use this option if the library is not in the folder that you have selected and you want to have the library JAR files placed there.

Use Relative Path to Library JAR Files. Use this option if the library is not in the libraries folder and you have to access the library in its existing location using a relative path. An entry with a relative reference is added for the library in the libraries folder's nblibraries.properties file.

Use Absolute Path to Library JAR Files. Use this option if the library is not in the libraries folder and you need to access the library in its existing location using an absolute path. An entry with an absolute reference is added for the library in the libraries folder's nblibraries.properties file.

Use Existing Library in Libraries Folder. Use this option if there is already a copy of the library in the libraries folder and you want to use that copy of the library.

Click Finish to exit the Make Project Sharable wizard.

Click OK to exit the Project Properties dialog box.

You can also use the Libraries node of the Project Properties dialog box to change the location of the libraries folder. If you have already specified a libraries folder, click Browse to open a file chooser instead of the New Libraries Folder wizard.

Note:

Free-form project libraries cannot be sharable in the ways described in this topic.

5.7.1 How to Add a Javadoc to a Project

When you add a required project to a project's classpath, the required project's Javadoc and sources are automatically added to the project as well.

To add Javadoc for a JAR file:

Choose Tools > Libraries from the main menu.

In the left pane of the Ant Library Manager, select the project library within which the JAR file you want to add Javadoc documentation to is located.

Only libraries already registered with the IDE are listed in the Ant Library Manager's Class Libraries list.

If the JAR file for which you want to add Javadoc documentation has not already been added to a registered library, create a new empty library using the New Library button. Next, in the Classpath tab click Add JAR/Folder and specify the location of the JAR file containing the compiled class files.

Note:

You can also associate the Javadoc with a JAR file using the project's Project Properties window. However, doing so creates the association only for that project. Open the Project Properties dialog box by right-clicking the project node and choosing Properties. Select the Libraries node in the Categories pane. Then select the JAR with which you want to associate the Javadoc and click Edit. You can then specify the sources to be associated.

A class library can contain multiple JAR files as well as their Javadoc documentation and source code.

In the Javadoc tab, click Add ZIP/Folder and specify the location of the Javadoc files.

Click OK to exit the Ant Library Manager.

The IDE adds the selected JAR files and Javadoc documentation ZIP files to the specified library and automatically registers the documentation in every project that has that JAR file on its classpath.

When you create a Java class library for a single JAR file, you can simply add the JAR file to the project's classpath to make the associated Javadoc and source code available. If your Java library contains multiple JAR files, however, you must add the library itself to the classpath. Adding the library to the classpath also makes it easier to share the project with other developers.

5.8 Setting the Target JDK

By default, the IDE uses the version of the Java SE platform (JDK) with which the IDE runs as the default Java platform for compilation, execution, and debugging. You can view your IDE's JDK version by choosing Help > About and clicking the Detail tab. The JDK version is listed in the Java field.

You can run the IDE with a different JDK version by starting the IDE with the --jdkhome jdk-home-dir switch on the command line or in your IDE-HOME/etc/netbeans.conf file. For more information, see Section 2.7, "Setting Startup Parameters."

You cannot enable JavaFX for the default registered Java platform. However, you can use the same JDK sources as the default platform in a new registered Java platform and enable JavaFX in the new platform.

5.8.1 How to Register a New Java Platform

In the IDE, you can register multiple Java platforms and attach Javadoc and source code to each platform. For example, if you want to work with the new features introduced in JDK 7, you would either run the IDE on JDK 7 or register JDK 7 as a platform and attach the source code and Javadoc to the platform. You can also enable JavaFX for multiple platforms.

To register a new Java platform:

Choose Tools > JavaPlatforms from the main window.

Click AddPlatform and select the directory that contains the Java platform. Java platform directories are marked with a icon in the file chooser. Click Next.

Specify the display name for the platform, the details of the remote device where an application is executed, your authentication details, and the path to the JRE on the remote device. Click Finish.

5.8.2 How to Set the Target JDK

In standard projects, you can switch the target JDK in the Project Properties dialog box. In free-form projects, you have to set the target JDK in the Ant script itself, then specify the source/binary format in the Project Properties dialog box.

To set the default Java platform for a standard project:

Right-click the project's root node in the Projects window and choose Properties.

In the Project Properties dialog box, select the Libraries node in the left pane.

In your Ant script, set the target JDK as desired in the javac, java, and javadoc tasks.

Right-click the project's root node in the Projects window and choose Properties.

In the Sources panel, set the level of JDK you want your application to be run on in the Source/Binary Format combo box.

When you access Javadoc or source code for JDK classes, the IDE searches the Java platforms registered in the Java Platform Manager for a platform with a matching version number. If no matching platform is found, the IDE's default platform is used instead.

In the Add Java Platform dialog, specify the display name for the platform, the details of the remote device where an application is executed and your authentication details. Click Create.

In the Create Java SE Embedded JRE dialog, click Browse and browse for the directory with JRE create on your hard drive.

Specify the path to the directory on a remote device where JRE must be installed and the required options. Click Create.

5.9 Moving, Copying, and Renaming a Project

When you create a project, the IDE bases much of its project metadata on the name and location of the project. These values are used in the project build scripts, the project properties, and the names and locations of the project folders.

5.9.1 How to Move, Copy, or Rename a Project

To safely move, copy, and rename a project, you must use the commands provided by the IDE.

To move, copy, or rename a project:

Right-click the project's node in the Projects window and choose one of the following commands:

RenameProject

MoveProject

CopyProject

Note:

When moving or copying a project to a new location, the new folder must already exist on the computer. You can create the folder with the Browse button.

Moving and renaming a project can break compilation dependencies between projects. To fix the project dependencies, remove the renamed or moved project from the classpath of any other projects, then add the project again

5.10 Deleting a Project

Deleting a project is a simple procedure and you have the option of deleting all project files or only the build scripts and metadata.

To delete a project:

Right-click the project's node in the Projects window and choose DeleteProject.

Specify whether to also delete the source folders under the project folder. If you do not select this option, the IDE only deletes the generated build scripts and project metadata.

The IDE does not offer to delete any source folders that are outside of the project folder.