Java Class Loader load(String className)

Here you can find the source of load(String className)

Description

load

License

Open Source License

Declaration

public static Class<?> load(String className) throws ClassNotFoundException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

public class Main {
    @SuppressWarnings("resource")
    public static Class<?> load(String jarpath, String className)
            throws ClassNotFoundException, MalformedURLException {
        URL url = new URL("file:" + jarpath);
        URLClassLoader myClassLoader = new URLClassLoader(new URL[] { url },
                Thread.currentThread().getContextClassLoader());
        return myClassLoader.loadClass(className);
    }//from   www.  ja  v a2 s .co m

    public static Class<?> load(String className) throws ClassNotFoundException {
        return Class.forName(className);
    }
}

Related

  1. getProjectClassLoader(IJavaProject javaProject, ClassLoader parentClassLoader)
  2. getStreamForPath(ClassLoader loader, String path)
  3. getToolsClassLoader()
  4. isBizServicesLocatorXmlLoaded(File f, ClassLoader classLoader)
  5. load(Class serviceClass, ClassLoader loader)
  6. load(String path, String className)
  7. loadAllAutoConfigFiles(ClassLoader classloader)
  8. loadArrayClass(ClassLoader cl, String aName)
  9. loadClass(ClassLoader cl, String cName)