I've inherited a Java project which is aimed at being a platform for multi-agent development. The idea is that you can create "applications" which run on the platform. I'm looking for a way to distribute the base platform such that the end users can add applications (likely packaged in jars) to a predefined folder, add a reference to the existence of said jar to some manifest file that the platform reads, and can therefore access files from it.
I've looked at the following answers, but these seem to require that the platform code know the names of classes at design-time:
Ideally, I'd like the following structure to work:
- Main directory: platform.jar, apps.manifest, Apps (directory)
- Apps/App1/app1.jar, Apps/App2/app2.jar, ..., Apps/AppN/appN.jar
apps.manifest will contain entries for each app, which will include the path to the jar, and the name of the class which is the main Application (implementing a common interface) object.
In my main code in platform.jar, I would like to read the manifest, notice that there are N applications, and be able to call ApplicationOne appOne = new ApplicationOne(this)
where ApplicationOne
is the name of the primary application object in app1.jar
, and this
is a reference to the object from platform.jar
which holds the reference to the application.
If all the jars (platform.jar
and the application jars) were all in the user's classpath, would it all work as above? If so, is there a way to temporarily add a directory (and all subdirectories) to the user's classpath in Java, which I could run when I run platform.jar
? I ask temporarily because the enclosing folder should be movable on the file system.
Any advice on the issue appreciated, as well as any advice on improving the question so it's clearer and easier to read.
Thanks