List of usage examples for java.lang ClassLoader getSystemClassLoader
@CallerSensitive public static ClassLoader getSystemClassLoader()
From source file:Main.java
public static void main(String[] args) { ClassLoader cl = ClassLoader.getSystemClassLoader(); cl.setDefaultAssertionStatus(true);/*from w ww .j ava2 s .c o m*/ new Loaded().go(); }
From source file:MainClass.java
public static void main(String[] args) { ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true); new Loaded().go(); }
From source file:Main.java
public static void main(String[] args) { ClassLoader cl = ClassLoader.getSystemClassLoader(); ResourceBundle bundle = ResourceBundle.getBundle("hello", Locale.US, cl); System.out.println(bundle.getString("hello")); }
From source file:Main.java
public static void main(String[] args) { ClassLoader sysClassLoader = ClassLoader.getSystemClassLoader(); URL[] urls = ((URLClassLoader) sysClassLoader).getURLs(); for (int i = 0; i < urls.length; i++) { System.out.println(urls[i].getFile()); }/*from w w w.ja va 2 s. c o m*/ }
From source file:Main.java
public static void main(String[] args) { ClassLoader cl = ClassLoader.getSystemClassLoader(); ResourceBundle.Control rbc = ResourceBundle.Control.getControl(Control.FORMAT_DEFAULT); ResourceBundle bundle = ResourceBundle.getBundle("hello", Locale.US, cl, rbc); System.out.println(bundle.getString("hello")); }
From source file:Main.java
public static void main(String[] args) { ResourceBundle bundle = ResourceBundle.getBundle("hello", Locale.US); System.out.println(bundle.getString("hello")); ClassLoader cl = ClassLoader.getSystemClassLoader(); ResourceBundle.clearCache(cl); }
From source file:Main.java
public static void main(String[] args) throws Exception { Main bean = (Main) Beans.instantiate(ClassLoader.getSystemClassLoader(), "Main"); System.out.println("The Bean = " + bean); }
From source file:Main.java
public static void main(String[] argv) throws Exception { MyBean bean = (MyBean) Beans.instantiate(ClassLoader.getSystemClassLoader(), "MyBean"); }
From source file:org.wso2.carbon.sample.consumer.JMSClient.java
public static void main(String[] args) throws InterruptedException { String broker = args[0];// w w w . j a va2 s .com String topic = args[1]; String queue = args[2]; Properties properties = new Properties(); try { boolean validBroker = true; if (broker.equalsIgnoreCase("qpid")) { properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("qpid.properties")); } else if (broker.equalsIgnoreCase("activemq")) { properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("activemq.properties")); } else if (broker.equalsIgnoreCase("mb")) { properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("mb.properties")); } else { validBroker = false; log.error("Entered broker is invalid! "); } if (validBroker) { if (topic != null && topic.isEmpty() || topic.equals("\"\"")) { topic = null; } if (queue != null && queue.isEmpty() || queue.equals("\"\"")) { queue = null; } if (topic == null && queue == null) { log.error("Enter topic value or queue value! "); } else if (topic != null) { Context context = new InitialContext(properties); TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) context .lookup("ConnectionFactory"); TopicConsumer topicConsumer = new TopicConsumer(topicConnectionFactory, topic); Thread consumerThread = new Thread(topicConsumer); log.info("Starting" + broker + "consumerTopic thread..."); consumerThread.start(); Thread.sleep(5 * 60000); log.info("Shutting down " + broker + " consumerTopic..."); topicConsumer.shutdown(); } else { Context context = new InitialContext(properties); QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) context .lookup("ConnectionFactory"); QueueConsumer queueConsumer = new QueueConsumer(queueConnectionFactory, queue); Thread consumerThread = new Thread(queueConsumer); log.info("Starting" + broker + "consumerQueue thread..."); consumerThread.start(); Thread.sleep(5 * 60000); log.info("Shutting down " + broker + " consumerQueue..."); queueConsumer.shutdown(); } } } 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:com.openx.oauthdemo.Demo.java
/** * Main class. OX3 with OAuth demo//www .ja va 2s .c o m * @param args */ public static void main(String[] args) { String apiKey, apiSecret, loginUrl, username, password, domain, path, requestTokenUrl, accessTokenUrl, realm, authorizeUrl; String propertiesFile = "default.properties"; // load params from the properties file Properties defaultProps = new Properties(); InputStream in = null; try { ClassLoader cl = ClassLoader.getSystemClassLoader(); in = cl.getResourceAsStream(propertiesFile); if (in != null) { defaultProps.load(in); } } catch (IOException ex) { System.out.println("The properties file was not found!"); return; } finally { if (in != null) { try { in.close(); } catch (IOException ex) { System.out.println("IO Error closing the properties file"); return; } } } if (defaultProps.isEmpty()) { System.out.println("The properties file was not loaded!"); return; } apiKey = defaultProps.getProperty("apiKey"); apiSecret = defaultProps.getProperty("apiSecret"); loginUrl = defaultProps.getProperty("loginUrl"); username = defaultProps.getProperty("username"); password = defaultProps.getProperty("password"); domain = defaultProps.getProperty("domain"); path = defaultProps.getProperty("path"); requestTokenUrl = defaultProps.getProperty("requestTokenUrl"); accessTokenUrl = defaultProps.getProperty("accessTokenUrl"); realm = defaultProps.getProperty("realm"); authorizeUrl = defaultProps.getProperty("authorizeUrl"); // log in to the server Client cl = new Client(apiKey, apiSecret, loginUrl, username, password, domain, path, requestTokenUrl, accessTokenUrl, realm, authorizeUrl); try { // connect to the server cl.OX3OAuth(); } catch (UnsupportedEncodingException ex) { Logger.getLogger(Demo.class.getName()).log(Level.SEVERE, "UTF-8 support needed for OAuth", ex); } catch (IOException ex) { Logger.getLogger(Demo.class.getName()).log(Level.SEVERE, "IO file reading error", ex); } catch (Exception ex) { Logger.getLogger(Demo.class.getName()).log(Level.SEVERE, "API issue", ex); } // now lets make a call to the api to check String json; try { json = cl.getHelper().callOX3Api(domain, path, "account"); } catch (IOException ex) { System.out.println("There was an error calling the API"); return; } System.out.println("JSON response: " + json); Gson gson = new Gson(); int[] accounts = gson.fromJson(json, int[].class); if (accounts.length > 0) { // let's get a single account try { json = cl.getHelper().callOX3Api(domain, path, "account", accounts[0]); } catch (IOException ex) { System.out.println("There was an error calling the API"); return; } System.out.println("JSON response: " + json); OX3Account account = gson.fromJson(json, OX3Account.class); System.out.println("Account id: " + account.getId() + " name: " + account.getName()); } }