-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
354f6c4
commit 1d0ebb8
Showing
3 changed files
with
34 additions
and
19 deletions.
There are no files selected for viewing
Binary file not shown.
24 changes: 24 additions & 0 deletions
24
UpdaterUpdater/src/at/chaosfield/updaterUpdater/JarRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package at.chaosfield.updaterUpdater; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.lang.reflect.Method; | ||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
|
||
public class JarRunner { | ||
|
||
private static final Class<?>[] parameters = new Class[]{URL.class}; | ||
|
||
public static void addFile(File file) throws IOException { | ||
URLClassLoader sysloader = (URLClassLoader)ClassLoader.getSystemClassLoader(); | ||
Class<?> sysclass = URLClassLoader.class; | ||
try { | ||
Method method = sysclass.getDeclaredMethod("addURL",parameters); | ||
method.setAccessible(true); | ||
method.invoke(sysloader,new Object[]{ file.toURI().toURL() }); | ||
} catch (Throwable t) { | ||
t.printStackTrace(); | ||
throw new IOException("Error, could not add File to system classloader"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters