581 total views, 14 views today

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.

100816_0442_Howtopackag1 How to package jar file with external library in JDeveloper 12C

 

2. Create a folder in the project by Right-click on the project >> Click New >> From Gallery >> Select Folder >> Click OK

100816_0442_Howtopackag2 How to package jar file with external library in JDeveloper 12C

3. Input the folder name as lib and click Ok

100816_0442_Howtopackag3 How to package jar file with external library in JDeveloper 12C

 

4. A folder called Resources get created in the project

100816_0442_Howtopackag4 How to package jar file with external library in JDeveloper 12C

 

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.

100816_0442_Howtopackag5 How to package jar file with external library in JDeveloper 12C

 

Create a Manifest File with Class-Path

1. Right click on the Project >>New >> From Gallery >> Select Folder >> Input name META-INF

100816_0442_Howtopackag6 How to package jar file with external library in JDeveloper 12C

 

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)

100816_0442_Howtopackag7 How to package jar file with external library in JDeveloper 12C

 

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

100816_0442_Howtopackag8 How to package jar file with external library in JDeveloper 12C

 

2. I have created a simple java class which prints class names of two java classes located in the jar files

100816_0442_Howtopackag9 How to package jar file with external library in JDeveloper 12C

 

Create a Deployment Profile

Double Click on the project >> Select the Deployment >> Click New Profile

100816_0442_Howtopackag10 How to package jar file with external library in JDeveloper 12C

 

Select profile type as jar file

100816_0442_Howtopackag11 How to package jar file with external library in JDeveloper 12C

 

Add the main class if exist and add the Manifest.MF file we created earlier

100816_0442_Howtopackag12 How to package jar file with external library in JDeveloper 12C

 

Select the Contributors >> Add the lib directory which contains the jar files >> Click Ok

100816_0442_Howtopackag13 How to package jar file with external library in JDeveloper 12C

 

Create an Executable jar file

Right click on the project >> Select Deploy >> Select the Profile we created >> Click Next >> Click Finish

100816_0442_Howtopackag14 How to package jar file with external library in JDeveloper 12C

 

Run the jar file

  1. 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>

100816_0442_Howtopackag15 How to package jar file with external library in JDeveloper 12C

govindan How to package jar file with external library in JDeveloper 12C
Connect me

Govind

Thank you for visiting my personal blog. Myself Govindan, Software Developer by profession since 2006 and hence I started this blog early in 2016 and ever since I've been writing about technologies experienced and learnings of everyday life.

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 šŸ™‚
govindan How to package jar file with external library in JDeveloper 12C
Connect me
Like us on Facebook.
Connect!