Example usage for java.lang ClassLoader getSystemClassLoader

List of usage examples for java.lang ClassLoader getSystemClassLoader

Introduction

In this page you can find the example usage for java.lang ClassLoader getSystemClassLoader.

Prototype

@CallerSensitive
public static ClassLoader getSystemClassLoader() 

Source Link

Document

Returns the system class loader.

Usage

From source file:org.kineticsystem.commons.util.ResourceLoader.java

/**
 * Return the url of the given resource.
 * @param path The resource path i.e/*from  w  ww  . ja  v a2 s  . c  o  m*/
 *     <tt>org/kineticsystem/commons/mymodule/bundle/test.txt</tt>.
 * @return The resource url.
 */
public static URL getResource(String path) {
    return ClassLoader.getSystemClassLoader().getResource(path);
}

From source file:czlab.wabbit.CljPodLoader.java

/**
 */// w  w w  .  j ava2 s  . c  o m
public static CljPodLoader newInstance(File homeDir, File appDir) {
    ClassLoader c = Thread.currentThread().getContextClassLoader();
    ClassLoader s = ClassLoader.getSystemClassLoader();
    CljPodLoader app = new CljPodLoader(c == null ? s : c);
    app.init(homeDir, appDir);
    return app;
}

From source file:org.apache.ambari.server.stack.StackManagerCommonServicesTest.java

public static StackManager createTestStackManager() throws Exception {
    String stack = ClassLoader.getSystemClassLoader().getResource("stacks_with_common_services").getPath();
    String commonServices = ClassLoader.getSystemClassLoader().getResource("common-services").getPath();
    return createTestStackManager(stack, commonServices);
}

From source file:org.ngrinder.NGrinderStarterTest.java

@Test
public void testNGrinderStarterJarResolution() {
    String path = ClassLoader.getSystemClassLoader().getResource(".").getPath();
    System.out.println(path);
}

From source file:br.univali.ps.fuzzy.portugolFuzzyCorretor.control.FileController.java

public static File carregarFuzzyRules() throws FileNotFoundException, IOException {
    final String caminho = "Portugol_Corretor_Rules.flc";
    final InputStream resourceStream = ClassLoader.getSystemClassLoader().getResourceAsStream(caminho);
    File PCR = new File("Portugol_Corretor_Rules.flc");

    try (OutputStream outputStream = new FileOutputStream(PCR)) {
        IOUtils.copy(resourceStream, outputStream);
    }/*w w  w .jav  a2  s .  c om*/

    return PCR;
}

From source file:org.wso2.carbon.integration.test.client.JMSConsumerClient.java

/**
 * This method will start the jms subscriber
 *
 * @param topic the topic which the consumer subscribe with the ActiveMQ broker
 *
 *///from  w  w  w.  j  a  v a 2  s  . com
public static void startConsumer(String topic) throws InterruptedException {
    messageCount = 0;
    active = true;
    Properties properties = new Properties();
    topicName = topic;
    preservedEventList = new ArrayList<>();
    try {
        properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("activemq.properties"));
        Context context = new InitialContext(properties);
        topicConnectionFactory = (TopicConnectionFactory) context.lookup("ConnectionFactory");
        JMSConsumerClient topicConsumer = new JMSConsumerClient();
        Thread consumerThread = new Thread(topicConsumer);
        log.info("Starting ActiveMQ consumerTopic thread...");
        consumerThread.start();
    } catch (IOException e) {
        log.error("Cannot read properties file from resources. " + e.getMessage(), e);
    } catch (NamingException e) {
        log.error("Invalid properties in the properties " + e.getMessage(), e);
    }
}

From source file:es.tekniker.framework.ktek.commons.config.ConfigFile.java

protected static void setFilePath(String defaultFilePath) throws IOException {
    ConfigFile.filePath = defaultFilePath;
    log.debug("Loading properties for file " + filePath);

    ClassLoader loader = ConfigFile.class.getClassLoader();
    if (loader == null)
        loader = ClassLoader.getSystemClassLoader();

    java.net.URL url = loader.getResource(filePath);
    props.load(url.openStream());/*from   w  w  w  .j a  v  a2 s. co m*/
    log.debug("Properties loaded");
}

From source file:de.micromata.genome.util.runtime.DynamicClassPath.java

public static void addSystemClassPath(URL url) {
    URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();
    PrivateBeanUtils.invokeMethod(sysloader, "addURL", url);
}

From source file:net.jselby.pc.bukkit.BukkitLoader.java

public static void addToClasspath(File file) throws Exception {
    Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[] { URL.class });
    method.setAccessible(true);/*from ww w. ja  va 2 s.co m*/
    method.invoke(ClassLoader.getSystemClassLoader(), new Object[] { file.toURI().toURL() });
}

From source file:com.commsen.jwebthumb.test.JWebThumbRequestsTest.java

@BeforeClass
public static void setApikey() throws IOException {
    apikey = IOUtils.toString(ClassLoader.getSystemClassLoader().getResourceAsStream("apikey.txt"));
    webThumbService = new WebThumbService(apikey);
}