Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File f = new File(nomJar);
- u = f.toURI().toURL();
- URLClassLoader loader = new URLClassLoader(new URL[]{u});
- JarFile jar = new JarFile(f.getAbsolutePath());
- Class jeu = Class.forName(nomClasse, true, loader);
- status.setText("Classe " + jeu.getName() + " chargée");
- Constructor constructors[] = jeu.getDeclaredConstructors();
- Constructor constructor = null;
- for(int i=0;i<constructors.length;i++){
- if(constructors[i].getParameterTypes().length == 0){
- constructor = constructors[i];
- }
- }
- if(constructor == null)
- status.setText("Impossible de trouver un constructeur valide");
- Method getNom = jeu.getDeclaredMethod("getNom",null);
- final Object instanceJeu = constructor.newInstance();
Add Comment
Please, Sign In to add comment