mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-12 18:57:38 +00:00
Fix Support for Java9
Add ElyBy in default load list
This commit is contained in:
1 parent
79404f659c
commit
7acef4d987
9 files changed
+49
-6
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package customskinloader.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class JavaUtil {
|
||||
public static URL[] getClasspath() {
|
||||
if (JavaUtil.class.getClassLoader() instanceof URLClassLoader) {
|
||||
//Java 8-
|
||||
//Use URLClassLoader Directly
|
||||
URLClassLoader ucl = (URLClassLoader) JavaUtil.class.getClassLoader();
|
||||
return ucl.getURLs();
|
||||
} else {
|
||||
//Java 9+
|
||||
//It uses APPClassLoader instead of URLClassLoader
|
||||
//Get Classpath from properties and parse it to URL array
|
||||
String classpath = System.getProperty("java.class.path");
|
||||
String[] elements = classpath.split(File.pathSeparator);
|
||||
if (elements.length == 0)
|
||||
return new URL[0];
|
||||
LinkedList<URL> urls = new LinkedList<URL>();
|
||||
for (String ele : elements) {
|
||||
try {
|
||||
urls.add(new URL(ele));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
return (URL[]) urls.toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user