Hello people,
At this moment we are building a framework that loads games, we load these games with *.jar files. We have it all working except one thing and that is using commands from out the framework, so what have have is this:
Loading jar files: (framework)
What we wanna do now is using a function inside the framework, the function is fired inside the jar file.. The class inside the jar file doesn't know the function in the framework, so how can we manage to get it work?Code:public loadJars(File file, boolean isCPU){
String url = file.toURI().toString().substring(6);
JarClassLoader loader = new JarClassLoader(url);
Class Mainclass = null;
try {
Mainclass = loader.loadClass("Main");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Object Mainobject = null;
try {
Mainobject = Mainclass.newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
if(Mainobject instanceof MainFrame){
Main = (MainFrame) Mainobject;
}
Framework.subscribeGame(Main.getGameName());
Framework_GUI.playerFound();
Main.setup(isCPU, Framework.getColor(), this);
if(Main.getColor()){
playerturn = true;
} else {
playerturn = false;
}
}
Thanks in advance

