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 need to use a library in several projects, create a special project within which to store it. Classpath and Standard Projects For standard projects, the IDE maintains separate classpaths for compiling and running your project, as well as compiling and running JUnit tests. The IDE automatically adds everything on your project's compilation classpath to the project's runtime classpath. Whenever you build a standard projects 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 Preparing a JAR for Deployment Outside the IDE To edit a standard project's classpath:
You can also add dependent projects and other required resources to a project by simply right-clicking the Libraries node in the Projects window and choosing the appropriate item (Project, Library, or JAR/Folder) from the contextual menu. 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. In order to change a free-form project's actual compilation or runtime classpath you must edit your build.xml file directly. Note that free-form projects do not have Library nodes nor do free-form project's Project Properties dialog boxes include a Libraries panel. For more information, see Declaring the Classpath in Free-Form Projects. The project's classpath declaration must exactly match the classpath used by your Ant script. -- Wagner R. Santos |