Sharing Libraries in a Java Project
See Also
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 need to 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.
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.
Then 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 will be
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.
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 will be
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 need 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.
Notes:
- 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, clicking Browse opens
a file chooser instead of the New Libraries Folder wizard.
- Free-form project libraries can not be sharable in the ways described in
this topic.
- The New Project wizard does not include the sharable libraries option for some standard
project templates, such as the Java Desktop Application. However, you can make such
projects sharable in the Project Properties dialog box.
- See Also
- Java Project Templates
- About Standard Projects
- About Free-Form Projects
- Working with Projects
- Project Tasks: Quick Reference
Legal Notices