I am wondering if it is possible to make any implementation of a specific Interface take a specific action automatically at the time when the Interface itself is initialized. Something like below:
public interface MyInterface {
public static final ArrayList<MyInterface> IMPLEMENTATIONS = new ArrayList<>();
public static void init(){
// Somecode...
}
void method1();
void method2();
}
I would like that when the interface is initialized, like if the init method is called, then a new instance of each class that implements the interface is to be created and added to the ArrayList.
The purpose of having something like this is to essentially have a single program that can start any other program I write and want available. Essentially, it is started when the computer starts and then can be used to start any other program I have written, instead of my having to add each new program to the system auto-start folder.
Is something like that possible?