Search code examples
javajarinternal

Java - How to make program run jar files internally


I was wondering ... I want to use a plugin-type thing with my Java program.

Here is the situation:

I have compiled a source file (.java) into a .jar file using MY .JAR program as a library. How to I make MY program run the other .jar file internally (using the main program as a reference).

I know this is weird (it sounds weird to me too), but if anyone understands what I am trying to say, please comment.

Thank you all in advance!


Solution

  • OK, here's a draft of how to do it.

    • Create an interface with a "run()" method.
    • Your .java plugin must implement that interface.
    • Load the all classes in classpath (help here Find Java classes implementing an interface)
    • run your plugin by executing the run method of the interface.