Guest User

Untitled

a guest
Mar 30th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. public class JavaNineLaunch {
  2. public static void main(String[] args) {
  3. try {
  4. new JavaNineLaunch().start(args);
  5. } catch (Exception e) {
  6. System.out.println(e);
  7. }
  8. }
  9. public void start(String[] args) throws Exception {
  10. Launch l = (Launch) Class.forName("net.minecraft.launchwrapper.Launch").newInstance();
  11. Method m = Launch.class.getDeclaredMethod("launch", String[].class);
  12. m.setAccessible(true); //Bypass private modifyer. EDIT: No work
  13.  
  14. if (getClass().getClassLoader() instanceof URLClassLoader) {
  15. final URLClassLoader ucl = (URLClassLoader) getClass().getClassLoader();
  16. l.classLoader = new LaunchClassLoader(ucl.getURLs());
  17. } else {
  18. l.classLoader = new LaunchClassLoader(getURLs());
  19. }
  20. l.blackboard = new HashMap<String,Object>();
  21. Thread.currentThread().setContextClassLoader(l.classLoader);
  22.  
  23. m.invoke(l, args);
  24. }
  25.  
  26. private URL[] getURLs() {
  27. String cp = System.getProperty("java.class.path");
  28. String[] elements = cp.split(File.pathSeparator);
  29. if (elements.length == 0) elements = new String[] {""};
  30. URL[] urls = new URL[elements.length];
  31. for (int i = 0; i < elements.length; i++) {
  32. try {
  33. URL url = new File(elements[i]).toURI().toURL();
  34. urls[i] = url;
  35. } catch (MalformedURLException ignore) {/*Ignore*/}
  36. }
  37. return urls;
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment