diff options
author | robotbrain <robotbrain@robotbrain.info> | 2015-04-05 08:18:08 -0400 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-04-19 19:07:39 +0200 |
commit | 07bebddac960bdee82c0a48a6925a49555f661ac (patch) | |
tree | bcfb7127928c8429a9c1da5afa82e4b234d17030 /depends/launcher/org/multimc/onesix/MMCClassLoader.java | |
parent | 4f417d527e8cf39d2c7653d80f1aade9155827de (diff) | |
download | MultiMC-07bebddac960bdee82c0a48a6925a49555f661ac.tar MultiMC-07bebddac960bdee82c0a48a6925a49555f661ac.tar.gz MultiMC-07bebddac960bdee82c0a48a6925a49555f661ac.tar.lz MultiMC-07bebddac960bdee82c0a48a6925a49555f661ac.tar.xz MultiMC-07bebddac960bdee82c0a48a6925a49555f661ac.zip |
NOISSUE Cleanup onesix launcher
Diffstat (limited to 'depends/launcher/org/multimc/onesix/MMCClassLoader.java')
-rw-r--r-- | depends/launcher/org/multimc/onesix/MMCClassLoader.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/depends/launcher/org/multimc/onesix/MMCClassLoader.java b/depends/launcher/org/multimc/onesix/MMCClassLoader.java new file mode 100644 index 00000000..ce8b806e --- /dev/null +++ b/depends/launcher/org/multimc/onesix/MMCClassLoader.java @@ -0,0 +1,35 @@ +package org.multimc.onesix; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.List; + +public class MMCClassLoader extends URLClassLoader +{ + public MMCClassLoader(String natives, List<String> allJars) + throws MalformedURLException, ClassNotFoundException, NoSuchMethodException, + InvocationTargetException, IllegalAccessException, NoSuchFieldException + { + super(process(allJars)); + Method setProperty = + loadClass("java.lang.System").getMethod("setProperty", String.class, String.class); + setProperty.invoke(null, "java.library.path", natives); + setProperty.invoke(null, "org.lwjgl.librarypath", natives); + setProperty.invoke(null, "net.java.games.input.librarypath", natives); + } + + private static URL[] process(List<String> allJars) throws MalformedURLException + { + URL[] urls = new URL[allJars.size()]; + for (int i = 0; i < allJars.size(); i++) + { + String jar = allJars.get(i); + urls[i] = new File(jar).toURI().toURL(); + } + return urls; + } +} |