Add Libraries Use the Add Libraries dialog to add libraries or resources to your project. You can also use this dialog to Add or Remove selected JAR and Zip files, library sources, and file folders with additional resources. To Add/Edit Libraries choose right-click the project node Properties. In the Project Properties dialog, select Build > Libraries & Resources and click the Add Library button. To add a library: Select a library from the list of installed libraries and click Add Library. To edit a library: Select a library from the list of installed libraries in the Add Library dialog box and click Edit Library. This opens the Library Manager, where you can edit the library. Click on one of the following tabs to edit the library's contents:
About Java Class Libraries A Java class library is a group of resources needed by a project. Typically a class library includes one or more JAR files containing compiled classes, the source files needed to debug the classes, and Javadoc documentation for the classes. In the IDE, you can create and edit libraries using the Library Manager. To open the Library Manager choose Tools > Libraries. By creating Java class libraries within which to store the JAR files on your project classpath, you can do the following: Group related JAR files that you use frequently. Add Javadoc documentation for your classes to a project. This enables you to automatically open the Javadoc page for any class in the library. Attach source code to your classes. This enables you to step through the source code when debugging your program or use the Go To Source command to open the source file. Notes: You can also associate sources or Javadoc documentation with an individual JAR file that you have added to your project. In the Projects window, right-click the project's node and choose Properties. Then select the Libraries panel, select the JAR file from the list of libraries, and click Edit. You can add references to sources and Javadoc documentation. You can configure a project to use a dedicated libraries folder in order to make it easier to share the project with other users. When you attach Javadoc documentation and source code to a JAR file in the Library Manager, the IDE automatically registers the documentation and source code in every project that has that JAR file on its classpath. You do not have to remove the JAR file from the classpath and add it as a library. 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 , 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 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: Expand the project node, right-click the Libraries node, and choose Properties. 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. 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. 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. |