0

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

Simon
  • 17
  • 5
  • Something like this maybe: http://stackoverflow.com/questions/60764/how-should-i-load-jars-dynamically-at-runtime – Bubletan Mar 27 '15 at 16:07

2 Answers2

1

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

Crazyjavahacking
  • 9,343
  • 2
  • 31
  • 40
0

I always put external libs in a directory for jar aplications in this way:

   dir
   |-myapp.jar
   └ lib
      |-mylib.jar
      └ log4j-1.2.14.jar 

Then I list the in libs the MANIFEST.MF for my application:

Class-Path: lib/mylib.jar lib/log4j-1.2.14.jar

dikey
  • 21
  • 4