public class JarClassLoader
extends java.lang.ClassLoader
implements java.io.Closeable
| Constructor and Description |
|---|
JarClassLoader(java.io.File file)
Constructs a new jar class loader that loads classes from the specified
file.
|
JarClassLoader(java.lang.String fileName)
Constructs a new jar class loader that loads classes from the jar file
with the given name in the local file system.
|
JarClassLoader(java.net.URL fileUrl,
long length)
Constructs a new jar class loader that loads classes from the specified
URL.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected java.lang.Package |
definePackage(java.lang.String name) |
protected java.lang.Package |
definePackage(java.lang.String name,
java.util.jar.Manifest man) |
protected java.lang.Class<?> |
findClass(java.lang.String name) |
protected java.net.URL |
findResource(java.lang.String name) |
java.io.InputStream |
getResourceAsStream(java.lang.String name) |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSignerspublic JarClassLoader(java.lang.String fileName)
throws java.io.IOException
fileName - The name of the jar filejava.io.IOException - if an I/O error occurspublic JarClassLoader(java.net.URL fileUrl,
long length)
throws java.io.IOException
fileUrl - The URL to load the jar file fromlength - The length of the jar file if known, -1
otherwisejava.io.IOException - if an I/O error occurspublic JarClassLoader(java.io.File file)
throws java.io.IOException
file - The file to load classes fromjava.io.IOException - if an I/O error occursprotected java.lang.Class<?> findClass(java.lang.String name)
throws java.lang.ClassNotFoundException
This method searches the temporary copy of the jar file for an entry that is specified by the given class name.
findClass in class java.lang.ClassLoaderjava.lang.ClassNotFoundExceptionClassLoader.findClass(java.lang.String)protected java.net.URL findResource(java.lang.String name)
Finds the resource within this jar only. If it isn't found within the jar, getResourceAsStream() will look elsewhere.
findResource in class java.lang.ClassLoaderpublic java.io.InputStream getResourceAsStream(java.lang.String name)
If the resource is found in this jar, opens the stream using ZipEntry's, so when tempJarFile is closed, so are all the streams, hence we can delete the jar on Windows.
getResourceAsStream in class java.lang.ClassLoaderClassLoader.getResourceAsStream(java.lang.String)protected java.lang.Package definePackage(java.lang.String name)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionprotected java.lang.Package definePackage(java.lang.String name,
java.util.jar.Manifest man)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException