Java Code Examples for java.net.URLClassLoader#findResources()

The following examples show how to use java.net.URLClassLoader#findResources() . 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: TestUrlClassLoader.java    From util4j with Apache License 2.0 6 votes vote down vote up
public static void testDir()throws Exception
	{
		File f=new File("C:/Users/Administrator/git/util4j/util4j/target/classes");
		URL url=f.toURI().toURL();
		URL[] urls=new URL[]{url};
		URLClassLoader loader=new URLClassLoader(urls);
//		loader.close();
		Class c1=loader.loadClass("net.jueb.util4j.math.CombinationUtil");
		System.out.println(c1);
		Class c2=loader.loadClass("net.jueb.util4j.math.CombinationUtil$CombinationController");
		System.out.println(c2);
		Class c3=loader.loadClass("net.jueb.util4j.math.CombinationUtil$ForEachByteIndexController");
		System.out.println(c3);
		Enumeration<URL> ss=loader.findResources("*.class");
		System.out.println(ss.hasMoreElements());
		CombinationUtil c22=(CombinationUtil) c1.newInstance();
		System.out.println(c22);
		loader.close();
		c1=loader.loadClass("net.jueb.util4j.math.CombinationUtil");
		System.out.println(c1);
	}
 
Example 2
Source File: Options.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Finds the <tt>META-INF/sun-jaxb.episode</tt> file to add as a binding customization.
 */
public void scanEpisodeFile(File jar) throws BadCommandLineException {
    try {
        URLClassLoader ucl = new URLClassLoader(new URL[]{jar.toURL()});
        Enumeration<URL> resources = ucl.findResources("META-INF/sun-jaxb.episode");
        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            addBindFile(new InputSource(url.toExternalForm()));
        }
    } catch (IOException e) {
        throw new BadCommandLineException(
                Messages.format(Messages.FAILED_TO_LOAD,jar,e.getMessage()), e);
    }
}
 
Example 3
Source File: Options.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Finds the <tt>META-INF/sun-jaxb.episode</tt> file to add as a binding customization.
 */
public void scanEpisodeFile(File jar) throws BadCommandLineException {
    try {
        URLClassLoader ucl = new URLClassLoader(new URL[]{jar.toURL()});
        Enumeration<URL> resources = ucl.findResources("META-INF/sun-jaxb.episode");
        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            addBindFile(new InputSource(url.toExternalForm()));
        }
    } catch (IOException e) {
        throw new BadCommandLineException(
                Messages.format(Messages.FAILED_TO_LOAD,jar,e.getMessage()), e);
    }
}
 
Example 4
Source File: Options.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Finds the <tt>META-INF/sun-jaxb.episode</tt> file to add as a binding customization.
 */
public void scanEpisodeFile(File jar) throws BadCommandLineException {
    try {
        URLClassLoader ucl = new URLClassLoader(new URL[]{jar.toURL()});
        Enumeration<URL> resources = ucl.findResources("META-INF/sun-jaxb.episode");
        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            addBindFile(new InputSource(url.toExternalForm()));
        }
    } catch (IOException e) {
        throw new BadCommandLineException(
                Messages.format(Messages.FAILED_TO_LOAD,jar,e.getMessage()), e);
    }
}
 
Example 5
Source File: Options.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Finds the <tt>META-INF/sun-jaxb.episode</tt> file to add as a binding customization.
 */
public void scanEpisodeFile(File jar) throws BadCommandLineException {
    try {
        URLClassLoader ucl = new URLClassLoader(new URL[]{jar.toURL()});
        Enumeration<URL> resources = ucl.findResources("META-INF/sun-jaxb.episode");
        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            addBindFile(new InputSource(url.toExternalForm()));
        }
    } catch (IOException e) {
        throw new BadCommandLineException(
                Messages.format(Messages.FAILED_TO_LOAD,jar,e.getMessage()), e);
    }
}
 
Example 6
Source File: Options.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Finds the {@code META-INF/sun-jaxb.episode} file to add as a binding customization.
 *
 * @param jar
 * @throws com.sun.tools.internal.xjc.BadCommandLineException
 */
public void scanEpisodeFile(File jar) throws BadCommandLineException {
    try {
        URLClassLoader ucl = new URLClassLoader(new URL[]{jar.toURL()});
        Enumeration<URL> resources = ucl.findResources("META-INF/sun-jaxb.episode");
        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            addBindFile(new InputSource(url.toExternalForm()));
        }
    } catch (IOException e) {
        throw new BadCommandLineException(
            Messages.format(Messages.FAILED_TO_LOAD, jar, e.getMessage()), e);
    }
}
 
Example 7
Source File: Options.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Finds the <tt>META-INF/sun-jaxb.episode</tt> file to add as a binding customization.
 */
public void scanEpisodeFile(File jar) throws BadCommandLineException {
    try {
        URLClassLoader ucl = new URLClassLoader(new URL[]{jar.toURL()});
        Enumeration<URL> resources = ucl.findResources("META-INF/sun-jaxb.episode");
        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            addBindFile(new InputSource(url.toExternalForm()));
        }
    } catch (IOException e) {
        throw new BadCommandLineException(
                Messages.format(Messages.FAILED_TO_LOAD,jar,e.getMessage()), e);
    }
}
 
Example 8
Source File: Options.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Finds the <tt>META-INF/sun-jaxb.episode</tt> file to add as a binding customization.
 */
public void scanEpisodeFile(File jar) throws BadCommandLineException {
    try {
        URLClassLoader ucl = new URLClassLoader(new URL[]{jar.toURL()});
        Enumeration<URL> resources = ucl.findResources("META-INF/sun-jaxb.episode");
        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            addBindFile(new InputSource(url.toExternalForm()));
        }
    } catch (IOException e) {
        throw new BadCommandLineException(
                Messages.format(Messages.FAILED_TO_LOAD,jar,e.getMessage()), e);
    }
}
 
Example 9
Source File: Options.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Finds the <tt>META-INF/sun-jaxb.episode</tt> file to add as a binding customization.
 */
public void scanEpisodeFile(File jar) throws BadCommandLineException {
    try {
        URLClassLoader ucl = new URLClassLoader(new URL[]{jar.toURL()});
        Enumeration<URL> resources = ucl.findResources("META-INF/sun-jaxb.episode");
        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            addBindFile(new InputSource(url.toExternalForm()));
        }
    } catch (IOException e) {
        throw new BadCommandLineException(
                Messages.format(Messages.FAILED_TO_LOAD,jar,e.getMessage()), e);
    }
}