62,615
社区成员
发帖
与我相关
我的任务
分享
import fxlauncher.Launcher;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
/**
* @Author: 李志锐
* @Date: 2018-12-19 17:44
*/
public class Application {
static {
String version = System.getProperty("java.specification.version");
System.out.println(version);
if ("1.7".equals(version)){
try {
String jrePath = System.getProperty("java.home");
String jfxrt = jrePath + "/lib/jfxrt.jar";
// 包路径定义
File file = new File(jfxrt);
if (file.exists()){
URL urls = file.toURL();
URLClassLoader urlLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
Class<URLClassLoader> sysclass = URLClassLoader.class;
Method method = sysclass.getDeclaredMethod("addURL", new Class[]{URL.class});
method.setAccessible(true);
method.invoke(urlLoader, urls);
}
}catch (Exception e){
e.printStackTrace();
}
}
}
public static void main(String[] args) {
Launcher.main(args);
}
}