sun.misc.Launcher Java Examples
The following examples show how to use
sun.misc.Launcher.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MyTest18.java From Project with Apache License 2.0 | 5 votes |
public static void main(String[] args) { // 启动类加载器默认的加载的类的路径 System.out.println(System.getProperty("sun.boot.class.path")); // 扩展类加载器默认的加载的类的路径 System.out.println(System.getProperty("java.ext.dirs")); // 系统类加载器默认的加载的类的路径 System.out.println(System.getProperty("java.class.path")); System.out.println(ClassLoader.class.getClassLoader()); // 上一行的运行结果是 null System.out.println(Launcher.class.getClassLoader()); // 上一行的运行结果是 null // 因为AppClassLoader和ExtClassLoader是位于Launcher内的静态内部类,既然Launcher类是由启动类加载器加载, // 那么AppClassLoader和ExtClassLoader也是由启动类加载器所加载。 System.out.println("---------------------------"); // 下面的代码和运行方式是 用来说明 自定义系统类加载器 的方法 System.out.println(System.getProperty("java.system.class.loader")); // 上一行的运行结果是 null。 说明默认情况下,java.system.class.loader 没有被定义 // // 在 MyTest16中追加 只有ClassLoader类型的参数的构造函数 // public MyTest16(ClassLoader parent) { // super(parent); // } // 运行命令 java -Djava.system.class.loader=zy.jvm.classloader.MyTest16 zy.jvm.classloader.MyTest18 // 指定了哪个类作为系统类加载器 /* zy.jvm.classloader.MyTest16 */ System.out.println(MyTest18.class.getClassLoader()); // IDEA直接运行和像上面一样用java命令运行,上一行的运行结果是 sun.misc.Launcher$AppClassLoader@135fbaa4。 System.out.println(MyTest16.class.getClassLoader()); // IDEA直接运行和像上面一样用java命令运行,上一行的运行结果是 sun.misc.Launcher$AppClassLoader@135fbaa4。 System.out.println(ClassLoader.getSystemClassLoader()); // IDEA直接运行,上一行的运行结果是 sun.misc.Launcher$AppClassLoader@135fbaa4。 // 像上面一样用java命令运行的结果是 zy.jvm.classloader.MyTest16@4e25154f }
Example #2
Source File: RuleFileParser.java From light with Apache License 2.0 | 5 votes |
static void loadRule() { final String path = "rule"; final File jarFile = new File(Rule.class.getProtectionDomain().getCodeSource().getLocation().getPath()); if(jarFile.isFile()) { // Run with JAR file try { final JarFile jar = new JarFile(jarFile); final Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar while(entries.hasMoreElements()) { final String name = entries.nextElement().getName(); if (name.startsWith(path + "/")) { //filter according to the path logger.debug(name); } } jar.close(); } catch (Exception e) { logger.error("Exception:", e); } } else { // Run with IDE final URL url = Launcher.class.getResource("/" + path); if (url != null) { try { final File apps = new File(url.toURI()); for (File app : apps.listFiles()) { logger.debug(app.getAbsolutePath()); } } catch (URISyntaxException ex) { // never happens } } } }
Example #3
Source File: JarUtils.java From ApkToolPlus with Apache License 2.0 | 5 votes |
public void test(String path) throws Exception { final File jarFile = getJarFile(null); if(jarFile.isFile()) { // Run with JAR file final JarFile jar = new JarFile(jarFile); final Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar while(entries.hasMoreElements()) { final String name = entries.nextElement().getName(); if (name.startsWith(path + "/")) { //filter according to the path System.out.println(name); } } jar.close(); } else { // Run with IDE final URL url = Launcher.class.getResource("/" + path); if (url != null) { try { final File apps = new File(url.toURI()); for (File app : apps.listFiles()) { System.out.println(app); } } catch (URISyntaxException e) { e.printStackTrace(); } } } }
Example #4
Source File: ClazzLoaderFactory.java From jhades with MIT License | 4 votes |
public static ClazzLoader createBootstrapClassLoader() { URLClassPath cp = Launcher.getBootstrapClassPath(); return new UrlClazzLoader(BOOTSTRAP_CLASS_LOADER, "N/A", cp.getURLs()); }
Example #5
Source File: AquaUtils.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
static boolean shouldUseOpaqueButtons() { final ClassLoader launcherClassLoader = Launcher.getLauncher().getClassLoader(); if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true; return false; }
Example #6
Source File: LauncherBootLoader.java From pinpoint with Apache License 2.0 | 4 votes |
private static URLClassPath getBootstrapClassPath() { return Launcher.getBootstrapClassPath(); }
Example #7
Source File: AquaUtils.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
static boolean shouldUseOpaqueButtons() { final ClassLoader launcherClassLoader = Launcher.getLauncher().getClassLoader(); if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true; return false; }
Example #8
Source File: AquaUtils.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
static boolean shouldUseOpaqueButtons() { final ClassLoader launcherClassLoader = Launcher.getLauncher().getClassLoader(); if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true; return false; }
Example #9
Source File: AquaUtils.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
static boolean shouldUseOpaqueButtons() { final ClassLoader launcherClassLoader = Launcher.getLauncher().getClassLoader(); if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true; return false; }
Example #10
Source File: AquaUtils.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
static boolean shouldUseOpaqueButtons() { final ClassLoader launcherClassLoader = Launcher.getLauncher().getClassLoader(); if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true; return false; }
Example #11
Source File: AquaUtils.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
static boolean shouldUseOpaqueButtons() { final ClassLoader launcherClassLoader = Launcher.getLauncher().getClassLoader(); if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true; return false; }
Example #12
Source File: AquaUtils.java From hottub with GNU General Public License v2.0 | 4 votes |
static boolean shouldUseOpaqueButtons() { final ClassLoader launcherClassLoader = Launcher.getLauncher().getClassLoader(); if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true; return false; }
Example #13
Source File: AquaUtils.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
static boolean shouldUseOpaqueButtons() { final ClassLoader launcherClassLoader = Launcher.getLauncher().getClassLoader(); if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true; return false; }
Example #14
Source File: AquaUtils.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
static boolean shouldUseOpaqueButtons() { final ClassLoader launcherClassLoader = Launcher.getLauncher().getClassLoader(); if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true; return false; }
Example #15
Source File: AquaUtils.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
static boolean shouldUseOpaqueButtons() { final ClassLoader launcherClassLoader = Launcher.getLauncher().getClassLoader(); if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true; return false; }
Example #16
Source File: AquaUtils.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
static boolean shouldUseOpaqueButtons() { final ClassLoader launcherClassLoader = Launcher.getLauncher().getClassLoader(); if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true; return false; }
Example #17
Source File: AquaUtils.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
static boolean shouldUseOpaqueButtons() { final ClassLoader launcherClassLoader = Launcher.getLauncher().getClassLoader(); if (classExists(launcherClassLoader, "com.installshield.wizard.platform.macosx.MacOSXUtils")) return true; return false; }