Search code examples
javaclasspathclassloadermanifest.mf

Java Application loading external jar


I am about to program a java application that is able to load extended functionality from an external directory that contains extension .jar files. I tried to specify that external directory within the MANIFEST.MF file's Class-Path property but unfortunately (by Oracle's specification) loading .jar files using wildcards is not supported / prohibited.

Using the -classpath option does not work as long as there is a manifest file in the main application jar.

Does anyone have an Idea how I can solve this problem. I there another possibility to specify an external .jar directory (either by a configuration file/setting or within the program). Thanks


Solution

  • Implement your own ClassLoader, which could simply extend URLClassLoader and add the URL of the extension directory to the classloader instance.