views:

75

answers:

2

Basically let me first explain what I am aiming to do. I have a dynamic ETL transformer app written in JAVA. Due to the dynamic nature of this app I have to be able to add plugins jars to the app in a location outside of the apps jar file. Basically would like to have the following directory structure:

AppFolder
|- plugins/
|- configs/
|- mainApp.jar

If possible I would like to be able to use wildcards in my manifest to dynamically add jars located in the plugins folder. Unfortunately all I have tried so far has failed. I have tried to use both relative paths and absolute paths neither have worked (with or without wildcard). If I however include the plugins folder in the main app's jar file itself it works fine given that I don't use wildcards.

So my question is, is it actually possible to have dependencies outside of a jar or do they always have to be contained within. The other question is regarding the usage of wildcards. i have looked at [the java documentation] (http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html) to no prevail unfortunately.

some examples of what I have tried so far:

  • ../plugins/*
  • ../plugins/plugin.jar
  • /abolute/path/to/plugins/*
  • /abolute/path/to/plugins/plugin.jar

and unfortunately none of them have done the trick so any help would be very much appreciated...

A: 

If you have control of the code you could always add a JarClassLoader and load the jars dynamically.
http://java.sun.com/docs/books/tutorial/deployment/jar/jarclassloader.html

Romain Hippeau
+2  A: 

Yes you can have dependencies outside the jar. But wildcards are not supported for specify dependant jars.

The jars need to be explicitly specified in your manifest, and the location needs to be relative to where the application is run from

A better option for you may be to use the Extension Mechanism

java -Djava.ext.dirs=/abolute/path/to/plugins/ ......
objects