Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class JavaNineLaunch {
- public static void main(String[] args) {
- try {
- new JavaNineLaunch().start(args);
- } catch (Exception e) {
- System.out.println(e);
- }
- }
- public void start(String[] args) throws Exception {
- Launch l = (Launch) Class.forName("net.minecraft.launchwrapper.Launch").newInstance();
- Method m = Launch.class.getDeclaredMethod("launch", String[].class);
- m.setAccessible(true); //Bypass private modifyer. EDIT: No work
- if (getClass().getClassLoader() instanceof URLClassLoader) {
- final URLClassLoader ucl = (URLClassLoader) getClass().getClassLoader();
- l.classLoader = new LaunchClassLoader(ucl.getURLs());
- } else {
- l.classLoader = new LaunchClassLoader(getURLs());
- }
- l.blackboard = new HashMap<String,Object>();
- Thread.currentThread().setContextClassLoader(l.classLoader);
- m.invoke(l, args);
- }
- private URL[] getURLs() {
- String cp = System.getProperty("java.class.path");
- String[] elements = cp.split(File.pathSeparator);
- if (elements.length == 0) elements = new String[] {""};
- URL[] urls = new URL[elements.length];
- for (int i = 0; i < elements.length; i++) {
- try {
- URL url = new File(elements[i]).toURI().toURL();
- urls[i] = url;
- } catch (MalformedURLException ignore) {/*Ignore*/}
- }
- return urls;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment