/** * Add a URL to the loader classpath only; does not update the system * classpath. * * @param url * The {@link URL} to add to the classpath */ public static void addURL(URL url) { loader.addURL(url); }
/** * The main program which actually runs JMeter. * * @param args * the command line arguments */ public static void main(String[] args) { if(!EXCEPTIONS_IN_INIT.isEmpty()) { System.err.println("Configuration error during init, see exceptions:"+exceptionsToString(EXCEPTIONS_IN_INIT)); } else { Thread.currentThread().setContextClassLoader(loader); setLoggingProperties(args); try { Class<?> initialClass = loader.loadClass("org.apache.jmeter.JMeter");// $NON-NLS-1$ Object instance = initialClass.newInstance(); Method startup = initialClass.getMethod("start", new Class[] { new String[0].getClass() });// $NON-NLS-1$ startup.invoke(instance, new Object[] { args }); } catch(Throwable e){ // NOSONAR We want to log home directory in case of exception e.printStackTrace(); // NOSONAR No logger at this step System.err.println("JMeter home directory was detected as: "+JMETER_INSTALLATION_DIRECTORY); } } }
/** * * @param urls - list of URLs to add to the thread's classloader */ public static void updateLoader(URL [] urls) { DynamicClassLoader loader = (DynamicClassLoader) Thread.currentThread().getContextClassLoader(); for(URL url : urls) { loader.addURL(url); } } }
/** * Add a URL to the loader classpath only; does not update the system classpath. * * @param path to be added. * @throws MalformedURLException when <code>path</code> points to an invalid url */ public static void addURL(String path) throws MalformedURLException { File furl = new File(path); loader.addURL(furl.toURI().toURL()); // See Java bug 4496398 File[] jars = listJars(furl); for (File jar : jars) { loader.addURL(jar.toURI().toURL()); // See Java bug 4496398 } }
/** * Add a directory or jar to the loader and system classpaths. * * @param path * to add to the loader and system classpath * @throws MalformedURLException * if <code>path</code> can not be transformed to a valid * {@link URL} */ public static void addPath(String path) throws MalformedURLException { File file = new File(path); // Ensure that directory URLs end in "/" if (file.isDirectory() && !path.endsWith("/")) {// $NON-NLS-1$ file = new File(path + "/");// $NON-NLS-1$ } loader.addURL(file.toURI().toURL()); // See Java bug 4496398 StringBuilder sb = new StringBuilder(System.getProperty(JAVA_CLASS_PATH)); sb.append(CLASSPATH_SEPARATOR); sb.append(path); File[] jars = listJars(file); for (File jar : jars) { loader.addURL(jar.toURI().toURL()); // See Java bug 4496398 sb.append(CLASSPATH_SEPARATOR); sb.append(jar.getPath()); } // ClassFinder needs this System.setProperty(JAVA_CLASS_PATH,sb.toString()); }