How to package jar file with external library in JDeveloper 12C
This section I have explained how to package jar file with third party jar files in JDeveloper 12C. The following are the series of steps required to package a jar file.
1. Create a lib directory in the existing project
2. Add third party jar files to the lib directory
3. Create a Manifest file with Class-Path
4. Create a Test java class (Optional)
5. Create a Deployment profile
6. Deploy it as executable jar file
7. Run the jar file
Create a lib directory in the project
1. As shown in the below image, I have created an empty java project in ADF application.
2. Create a folder in the project by Right-click on the project >> Click New >> From Gallery >> Select Folder >> Click OK
3. Input the folder name as lib and click Ok
4. A folder called Resources get created in the project
Add jar files to the lib directory
5. Go to the PROJECT\lib directory in file explorer. Add the project dependency jar files over there.
Create a Manifest File with Class-Path
1. Right click on the Project >>New >> From Gallery >> Select Folder >> Input name META-INF
2. A folder called OEP Content created in the project. Create a file called MANIFEST.MF. Input the jar files in the lib directory in Class-Path with space separated
Make sure to hit Enter after the line (Carriage return)
Create a Test java class
1. Double click on the project >> Go to Libraries and Classpath >> Click the Add Jar/Directory >> Add the jar files
2. I have created a simple java class which prints class names of two java classes located in the jar files
Create a Deployment Profile
Double Click on the project >> Select the Deployment >> Click New Profile
Select profile type as jar file
Add the main class if exist and add the Manifest.MF file we created earlier
Select the Contributors >> Add the lib directory which contains the jar files >> Click Ok
Create an Executable jar file
Right click on the project >> Select Deploy >> Select the Profile we created >> Click Next >> Click Finish
Run the jar file
- The jar files got created under the deploy directory of the project by default. The jar files holds all the external jars.
2. Open a command prompt and execute the jar file.
Java -jar <JAR FILE>
The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.
Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply 🙂
Latest posts by Govind
- JSF Login Logout Form Authentication Example - October 16, 2017
- How to Bookmark URL in JSF using GET method and ViewParam – example - October 14, 2017
- JSF Dynamic Navigation and how to use wildcard in navigation - October 12, 2017