public class ClassLoaderUtil extends Object
ClassLoader
utility.Constructor and Description |
---|
ClassLoaderUtil() |
Modifier and Type | Method and Description |
---|---|
static ClassLoader |
createClassloader(File libDir,
ClassLoader cl)
Deprecated.
removal candidate, never used
|
static URLClassLoader |
createURLClassLoader(String dirPath)
Construct a
URLClassLoader based on a canonical file location. |
static URLClassLoader |
createURLClassLoader(String location,
ClassLoader parent)
Construct a
URLClassLoader based on a canonical file location. |
static Object |
load(String clazzName)
Load a class using the current {link Thread#getContextClassLoader}
|
static Object |
load(String clazzName,
ClassLoader classLoader)
Load a class using the provided
ClassLoader |
public static ClassLoader createClassloader(File libDir, ClassLoader cl) throws IOException
libDir
- Directory with jars.cl
- the parent ClassLoader
, or null if none.URLClassLoader
that can load classes from a directory that
contains jar and zip files.IOException
- I/O failpublic static URLClassLoader createURLClassLoader(String dirPath) throws IOException
URLClassLoader
based on a canonical file location.dirPath
- a canonical path locationURLClassLoader
IOException
- I/OMalformedURLException
- Invalid URLpublic static URLClassLoader createURLClassLoader(String location, ClassLoader parent) throws IOException
URLClassLoader
based on a canonical file location.location
- a canonical path locationparent
- ClassLoader
to be used as parent for returned one.URLClassLoader
IOException
- I/OMalformedURLException
- Invalid URLpublic static Object load(String clazzName)
clazzName
- The name of the class you want to load.public static Object load(String clazzName, ClassLoader classLoader)
ClassLoader
clazzName
- The name of the class you want to load.classLoader
- A classloader to use for loading a class.Copyright © 2014 Oracle Corporation. All rights reserved.