WAS v8.5 > Administer applications and their environment > Administer the Liberty profile > Administer the Liberty profile using WebSphere Studio
Define a utility project as a shared library
We can define a utility project as a shared library and associate defined shared libraries with an application or web project.
To use the shared library function in the workbench, you must create a utility project and define it as a shared library. The utility project is the only project type that can be used as a shared library.
A shared library is an external Java™ archive (JAR) file used by one or more applications. Using shared libraries enables multiple application published on a server to use a single library, rather than use multiple copies of the same library. After you associate shared libraries with an application or project, the application or module class loader loads classes in the shared libraries and makes those classes available to the application or module.
To define a utility project as a shared library:
- Create a utility project:
- In the toolbar, select File > New > Project.
- Expand Java EE and select Utility Project. Click Next.
- In the Project name field, specify a name for the utility project.
- Under the Target runtime section, verify the WebSphere Application Server Liberty profile is selected.
- Under the Ear membership section, clear the Add project to an EAR check box.
- Click Finish.
- Define the artifacts in the newly created utility project. For example, we can add Java classes to the utility project.
- Define the utility project as a shared library:
- In the Project Explorer view, right-click the utility project and select Properties > Liberty Profile Shared Library.
- In the Shared library ID field, type a string as an identifier for the shared library.
- In the Archive directory field, type or browse to a directory where to place the compressed copy of your utility project as a JAR file. The file name convention of the JAR file is utilityProjectName.jar, where utilityProjectName is the name of the utility project.
- In the Liberty Profile Shared Library page, click Apply to confirm your changes. Click OK to close the Properties window.
- Add the utility project to the server. For more details see Add and running an application on the Liberty profile using WebSphere Studio topic.
ResultsHere is an example entry added to the server configuration (server.xml) file:
- Setting a web project to use shared libraries
If we have a utility project defined as a shared library, we can associate defined shared libraries with a web project.
Parent topic: Administer the Liberty profile using WebSphere Studio
Configure class loaders and libraries for Java EE applications
Sharing a library across multiple Java EE applications
Overriding a provided API with an alternative version