|
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.jcardshark.blackjack.ui
package, you add the folder that contains thecom
folder.Standard. You can have multiple source folders in a single project, but these source folders all share the same classpath and are packaged into the same JAR file or WAR file. Each project represents a single compilation unit. To work with source folders that are in different compilation units, you should create separate projects and put the projects on each other's classpath as necessary.
Free-Form. You can have multiple source folders and define complex classpath relationships between folders.
The project folder contains the Ant script and properties files that control how your project is built and run.
Standard. The project folder contains two Ant scripts:
- nbproject/build-impl.xml. Contains the instructions for handling your project. This file is generated by the IDE and should not be edited.
- build.xml. Imports targets from build-impl.xml. You can edit this file to override existing targets or create new targets.
The project folder also contains the output folder for compiled classes, JAR files (for J2SE projects) or WAR files (for web projects) files, and Javadoc.
Free-Form. When you specify the Location in the free-form project, this location does not necessarily need to be the folder that contains the Ant script. For example, if you have all of your source package folders organized into one folder, you could set that folder as the project location even if it does not contain the Ant build script. The location of the output folders depends on how your Ant script is configured.
The Java BluePrints Project Conventions specify recommended conventions for structuring J2EE applications. The conventions are intended to assist developers with organizing the files and directories associated with an application project in a logical fashion. To import an Enterprise Application from Existing Source, your application must follow the BluePrints conventions.
The illustration below shows the BluePrints conventions for enterprise applications. For more information, see http://java.sun.com/blueprints/code/projectconventions.html.
The web module root is the top-level folder of a web application. It is where your JSP pages, client-side classes and archives, and static web resources, such as images, are stored. The illustration below shows the source structure of a typical web application.
When your application is organized into several projects, the main project serves as the entry point to the application. Usually, the main project contains the main class that starts the application. For enterprise applications, the main project should always be the enterprise application project that contains the EJB modules and Web modules.
Many menu commands such as Run and Build have keyboard shortcuts to the main project. You can also access all commands for individual projects by right-clicking their project nodes in the Projects window.
To make a project the main project, right-click the project's node in the Projects window and choose Set Main Project.
Free-form projects rely on your Ant script to provide targets for all IDE actions, including:
- Building
- Cleaning
- Compiling the project
- Compiling a single file
- Compiling a JavaServer Pages file
- Running the project
- Running a single file
- Generating Javadoc
- Running JUnit tests
- Running the project in the debugger
- Running a single file in the debugger
- Applying code changes and continuing debugging
- Redeploying a web project
If your Ant script does not contain targets for any of these actions and you run the command associated with the action, the IDE generates a basic Ant target for the action in a separate ide-targets.xml build script. In most cases, you have to manually edit the generated build scripts to specify information like the project's classpath and main class.
For more information, see Advanced Free-Form Project Configuration.
The Projects window shows a package-based view of your projects. You can right-click the project node to run commands on the project. You can configure project options by right-clicking the project node and choosing Properties.
For enterprise applications, the Projects window also groups other types of files in logical nodes. See Enterprise Applications below for more information.
The Files window shows you the physical layout of your project files on disk. The project folder and each of your source folders are displayed for each of your projects. The
nbproject
folder contains project metadata for your project.
Standard. When you add classes to a project's classpath, the IDE makes these classes available for code completion and refactoring. You can add the following types of classpath elements to a project:
- JAR file. A packaged library of compiled Java classes for J2SE projects only.
- WAR file. A packaged library of compiled web classes for web projects only.
- Library. A collection of compiled classes (JAR/WAR file), source code for debugging, and Javadoc. You can create a library by choosing Tools > Library Manager from the main window.
- Project. The build output (JAR/WAR file), source code for debugging, and Javadoc from another NetBeans IDE project. When you add a required project to a project, all of the JAR/WAR files for both projects are built when you build the main project. (In the J2SE example, building BlackJackUI also builds the required project BlackJackLib.)
Free-Form. Your Ant script must explicitly handle the classpath elements for compilation and execution. The classpath settings that you enter when creating the project are used to provide code completion, error highlighting, and refactoring for your project. These classpath settings must match the classpath definition in your Ant script. You can set one classpath for the entire project or set the classpath for each individual source folder in your project. To declare the classpath for an existing free-form project, right-click the project node in the Projects window and choose Properties. Then click Classpath and set the classpath for each source root.
The context provides a way to distinguish resources in one web application from resources in others that are deployed on the same server instance.
The context of an application determines the URL namespace of the contents of the web application. When a web application's context property value is set, you access the web module at http://hostname:port/context/servlet_or_jsp. For example, with the property value set to /HelloWeb, you access the web application at http://hostname:port/HelloWeb/index.jsp.
Note that the context path is preceded by a forward slash and that it should not contain spaces.
In order to develop J2EE applications, you need to have a local instance of the application installed on your computer and registered in the IDE. The IDE uses libraries and tools from your local installation to enable compilation and generation of source code for enterprise application projects. Once you have registered a local instance of the Sun Java System application server, you can register multiple remote instances of the server to which you can deploy your enterprise applications.
The Sun Java System Application Server, Platform Edition is free for development and deployment.