Ajouter un argument à la VM en cours d'execution
speedzealot
Messages postés
18
Date d'inscription
Statut
Membre
Dernière intervention
-
speedzealot Messages postés 18 Date d'inscription Statut Membre Dernière intervention -
speedzealot Messages postés 18 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
J'aimerai déplacer mes arguments de la JVM dans ma class main.
Donc au lieu de configurer Eclipse avec comme VMargs : -Djava.library.path=Slick2D, je voudrai mettre à la première ligne de mon main :
Sauf que j'ai le droit à une erreur "no lwjgl in java.library.path" ...
(Sachant que dans la librairie Slick2D j'ai bien sure lwjgl.jar, et que si je met
sur la ligne suivante, j'ai bien mon "Slick2D" ...)
j'aimerai quand même comprendre
(ce serai pour pouvoir lancer mon programme sans passer par un script/batch)
Merci
J'aimerai déplacer mes arguments de la JVM dans ma class main.
Donc au lieu de configurer Eclipse avec comme VMargs : -Djava.library.path=Slick2D, je voudrai mettre à la première ligne de mon main :
System.getProperties().put("java.library.path", "Slick2D"); // ou System.setProperties("java.library.path", "Slick2D");
Sauf que j'ai le droit à une erreur "no lwjgl in java.library.path" ...
(Sachant que dans la librairie Slick2D j'ai bien sure lwjgl.jar, et que si je met
System.out.println(System.getProperties().getProperty("java.library.path"));
sur la ligne suivante, j'ai bien mon "Slick2D" ...)
j'aimerai quand même comprendre
(ce serai pour pouvoir lancer mon programme sans passer par un script/batch)
Merci
A voir également:
- Ajouter un argument à la VM en cours d'execution
- Vm windows - Guide
- Panne tnt en cours aujourd'hui - Guide
- En cours de livraison ✓ - Forum Consommation & Internet
- En cours d'acheminement - Forum Consommation & Internet
- Impossible d'ajouter un ami sur facebook - Guide
1 réponse
Ok c'est bon je l'ai :)
il est aussi dit que cela ne marcherai pas sur toutes les plateformes/JVM.
marche avec windows7 64 bits, jre7 32bits
Pour plus de details : https://stackoverflow.com/questions/5419039/is-djava-library-path-equivalent-to-system-setpropertyjava-library-path
public static void addLibPath(String s){ try { Field field = ClassLoader.class.getDeclaredField("usr_paths"); field.setAccessible(true); String[] paths = (String[])field.get(null); for (int i = 0; i < paths.length; i++) if (s.equals(paths[i])) return; String[] tmp = new String[paths.length+1]; System.arraycopy(paths, 0, tmp, 0, paths.length); tmp[paths.length] = s; field.set(null,tmp); System.setProperty("java.library.path", System.getProperty("java.library.path") + File.pathSeparator + s); } catch (IllegalAccessException e) { System.err.println("Failed to get permissions to set library path"); e.printStackTrace(); } catch (NoSuchFieldException e) { System.err.println("Failed to get field handle to set library path"); e.printStackTrace(); } }
il est aussi dit que cela ne marcherai pas sur toutes les plateformes/JVM.
marche avec windows7 64 bits, jre7 32bits
Pour plus de details : https://stackoverflow.com/questions/5419039/is-djava-library-path-equivalent-to-system-setpropertyjava-library-path
ce qui m'amène à une question : peut-on creer une bibliothèque en cours d'execution (dans le main) ?