I want a mechanism that will allow to dynamically load and unload jars as well as calling an activator class in the jar. I don't want to use OSGi because of the cumbersome import/export mechanism.
views:
308answers:
3JavaRebel, but it is mostly appropriate for development, not a production deployment. If you are looking for an open source alternative, you can follow this question.
You can use the ClassLoader to dynamically load classes from JAR files. When you have dynamically loaded the class, you can explicitly invoke an initialization routine if necessary. Like the rest of Java, this mechanism is garbage-collected, so there is no way to explicitly unload the JAR; it is up to the JVM to release the JAR when the dynamically loaded classes are no longer referenced and garbage collection has run.
There's a project called the Java Plugin Framework that might be what you're looking for. On their web page it states the project is an attempt to match and extend Eclipse's pre-OSGI plugin architecture. It's a generic framework and isn't tied to SWT/desktop apps.