Adding jar files available in folder of a physical machine into server classpath by using MANIFEST.MF of war file

I have a doubt regarding adding a jar into server classpath. If a jar is required to be added, we will add in lib folder of war OR we will add the jar in server's lib folder.

But, I would like to add a jar available in a absolute folder in my machine say C:\test.jar into the classpath. Could this be possible.

I have tried adding the entry Class-path: C:/test.jar in the MANIFEST.MF of war file to do that and when war is deployed, I got classNotFoundException related to test.jar.

This means the jar test.jar is not added from MANIFEST.MF of war file into server classpath while deploying.

Am I missing something here OR is this not possible at all. Please note that the intention is to keep jar files in a separate folder in my machine and load the same in the server classpath by using MANIFEST.MF of war file. Kindly help me out.

Answers


In manifest.mf you can either have relative path or URL's. Try to convert your path to url as below,

file://C:/test.jar

But few suggestions, since you mentioned it is a webapp why not considering creating a shared library ?


Put in your manifest the class-path with this format (win):

Class-Path: /test.jar

or

Class-Path: file:\\\\c:\\test.jar

and remember to put a new line at the end of the line

However every application server has a better method to share libraries, which one do you use?


Need Your Help

Let the user choose from a range of numbers in preference screen

android android-preferences

I would like the user to be able to enter/pick a number in between 300 and 2000. I tought of useing EditTextPreference but then I wouldn't know how to check if the value is actually in range. i'm v...