I am working on a program that is supposed to have โModulesโ that people can create their own code from the API, and then they can add one of their own Modules, let them say itโs called ModuleNicerText, they add it to the folder MyProgram\Modulesas a class. java (source), and the class implements Module.
The class Modulehas one method (well, it has more, but I will say one for this post) , called onUpdate(), and I want to be able to somehow import this class into my code, and then run .onUpdate()whenever I need, I hope that I explained it well enough, if I donโt, then here is another example:
I have an interface named Module
this body Module:
public interface Module {
void onUpdate();
}
Now I have my main class with a name MyProgram, and in this class I have this method:
public void onUpdate(){
for (Module module : modules){
module.onUpdate();
}
}
I use such a system, so I can easily add or remove components without having to mess with a bunch of things, if all this is filled with one class / method.
Now there is a directory that is created when the program starts, which MyProgram\Modules, and anyone who wants to, can add a .java file that extends the interface there Module.
I want to be able to view .java files in this directory and be able to call a method .onUpdate()for them so that my users can have as many settings as possible!
, , , :)