<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.lang.ClassLoader
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.lang.html">This Package</a>  <a href="java.lang.Class.html#_top_">Previous</a>  <a href="java.lang.Compiler.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.lang.ClassLoader
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----java.lang.ClassLoader
</pre>
<hr>
<dl>
  <dt> public abstract class <b>ClassLoader</b>
  <dt> extends <a href="java.lang.Object.html#_top_">Object</a>
</dl>
The class <code>ClassLoader</code> is an abstract class. 
 Applications implement subclasses of <code>ClassLoader</code> in 
 order to extend the manner in which the Java Virtual Machine 
 dynamically loads classes. 
 <p>
 Normally, the Java Virtual Machine loads classes from the local 
 file system in a platform-dependent manner. For example, on UNIX 
 systems, the Virtual Machine loads classes from the directory 
 defined by the <code>CLASSPATH</code> environment variable. 
 <p>
 However, some classes may not originate from a file; they may 
 originate from other sources, such as the network, or they could 
 be constructed by an application. The method 
 <code>defineClass</code> converts an array of bytes into an 
 instance of class <code>Class</code>. Instances of this newly 
 defined class can be created using the <code>newInstance</code> 
 method in class <code>Class</code>. 
 <p>
 The methods and constructors of objects created by a class loader 
 may reference other classes. To determine the class(es) referred 
 to, the Java Virtual Machine calls the <code>loadClass</code> 
 method of the class loader that originally created the class. If 
 the Java Virtual Machine only needs to determine if the class 
 exists and if it does exist to know its superclass, the 
 <code>resolve</code> flag is set to <code>false</code>. However, 
 if an instance of the class is being created or any of its methods 
 are being called, the class must also be resolved. In this case 
 the <code>resolve</code> flag is set to <code>true</code>, and the 
 <code>resolveClass</code> method should be called. 
 <p>
 For example, an application could create a network class loader 
 to download class files from a server. Sample code might look like:
 <ul><code>
   ClassLoader loader&nbsp;= new NetworkClassLoader(host,&nbsp;port);<br>
   Object main&nbsp;= loader.loadClass("Main", true).newInstance();<br>
	 &nbsp;.&nbsp;.&nbsp;.
 </code></ul>
 <p>
 The network class loader subclass must define the method 
 <code>loadClass</code> to load a class from the network. Once it 
 has downloaded the bytes that make up the class, it should use the 
 method <code>defineClass</code> to create a class instance. A 
 sample implementation is: 
 <p><hr><blockquote><pre>
     class NetworkClassLoader {
         String host;
         int port;
         Hashtable cache = new Hashtable();
         private byte loadClassData(String name)[] {
         // load the class data from the connection
         &nbsp;.&nbsp;.&nbsp;.
         }
         public synchronized Class loadClass(String name,
                                             boolean resolve) {
             Class c = cache.get(name);
             if (c == null) {
                 byte data[] = loadClassData(name);
                 c = defineClass(data, 0, data.length);
                 cache.put(name, c);
             }
             if (resolve)
                 resolveClass(c);
             return c;
         }
     }
 </pre></blockquote><hr>
<p>
<dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.lang.Class.html#_top_">Class</a>, <a href="java.lang.Class.html#newInstance()">newInstance</a>, <a href="#defineClass(byte[], int, int)">defineClass</a>, <a href="#loadClass(java.lang.String, boolean)">loadClass</a>, <a href="#resolveClass(java.lang.Class)">resolveClass</a>
</dl>
<hr>
<a name="index"></a>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#ClassLoader()"><b>ClassLoader</b></a>()
  <dd>  Constructs a new class loader and initializes it.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#defineClass(byte[], int, int)"><b>defineClass</b></a>(byte[], int, int)
  <dd>  Converts an array of bytes into an instance of class 
 <code>Class</code>.
<b>Deprecated.</b>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#defineClass(java.lang.String, byte[], int, int)"><b>defineClass</b></a>(String, byte[], int, int)
  <dd>  Converts an array of bytes to an instance of class
 Class.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#findLoadedClass(java.lang.String)"><b>findLoadedClass</b></a>(String)
  <dd>  
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#findSystemClass(java.lang.String)"><b>findSystemClass</b></a>(String)
  <dd>  Finds the system class with the specified name, loading it in if 
 necessary.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getResource(java.lang.String)"><b>getResource</b></a>(String)
  <dd>  Find a resource with a given name.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getResourceAsStream(java.lang.String)"><b>getResourceAsStream</b></a>(String)
  <dd>  Get an InputStream on a given resource.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getSystemResource(java.lang.String)"><b>getSystemResource</b></a>(String)
  <dd>  Find a resource with a given name.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getSystemResourceAsStream(java.lang.String)"><b>getSystemResourceAsStream</b></a>(String)
  <dd>  Get an InputStream on a given resource..
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#loadClass(java.lang.String)"><b>loadClass</b></a>(String)
  <dd>  Requests the class loader to load and resolve a class with the specified 
 name.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#loadClass(java.lang.String, boolean)"><b>loadClass</b></a>(String, boolean)
  <dd>  Resolves the specified name to a Class.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#resolveClass(java.lang.Class)"><b>resolveClass</b></a>(Class)
  <dd>  Resolves the class so that an instance of the class can be 
 created, or so that one of its methods can be called.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setSigners(java.lang.Class, java.lang.Object[])"><b>setSigners</b></a>(Class, Object[])
  <dd>  Sets the signers of a class.
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="ClassLoader"></a>
<a name="ClassLoader()"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>ClassLoader</b>
<pre>
 protected ClassLoader()
</pre>
<dl>
  <dd> Constructs a new class loader and initializes it. 
 <p>
 If there is a security manager, its 
 <code>checkCreateClassLoader</code> method is called. This may 
 result in a security exception.
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.lang.SecurityException.html#_top_">SecurityException</a>
    <dd> if the current thread does not have
               permission to create a new class loader.
    <dt> <b>See Also:</b>
    <dd> <a href="java.lang.SecurityException.html#_top_">SecurityException</a>, <a href="java.lang.SecurityManager.html#checkCreateClassLoader()">checkCreateClassLoader</a>
  </dl></dd>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="loadClass(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="loadClass"><b>loadClass</b></a>
<pre>
 public <a href="java.lang.Class.html#_top_">Class</a> loadClass(<a href="java.lang.String.html#_top_">String</a> name) throws <a href="java.lang.ClassNotFoundException.html#_top_">ClassNotFoundException</a>
</pre>
<dl>
  <dd> Requests the class loader to load and resolve a class with the specified 
 name. The <code>loadClass</code> method is called by the Java 
 Virtual Machine when a class loaded by a class loader first 
 references another class. Every subclass of class 
 <code>ClassLoader</code> must define this method. 
 <p>
 Class loaders should use a hashtable or other cache to avoid 
 defining classes with the same name multiple times.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> name - the name of the desired <code>Class</code>.
    <dt> <b>Returns:</b>
    <dd> the resulting <code>Class</code>, or <code>null</code>
             if it was not found.
    <dt> <b>Throws:</b> <a href="java.lang.ClassNotFoundException.html#_top_">ClassNotFoundException</a>
    <dd> if the class loader cannot find
               a definition for the class.
  </dl></dd>
</dl>
<a name="loadClass(java.lang.String, boolean)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="loadClass"><b>loadClass</b></a>
<pre>
 protected abstract <a href="java.lang.Class.html#_top_">Class</a> loadClass(<a href="java.lang.String.html#_top_">String</a> name,
                                    boolean resolve) throws <a href="java.lang.ClassNotFoundException.html#_top_">ClassNotFoundException</a>
</pre>
<dl>
  <dd> Resolves the specified name to a Class. The method loadClass() is 
 called by the virtual machine.
 <p>
 If the <code>resolve</code> flag is true, the method should call 
 the <code>resolveClass</code> method on the resulting class object.
 <p>
 As an abstract method, loadClass() must be defined in a subclass of 
 ClassLoader. By using a Hashtable, you can avoid loading the same 
 Class more than once.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> name - the name of the desired Class.
    <dd> resolve - true if the Class needs to be resolved.
    <dt> <b>Returns:</b>
    <dd> the resulting Class, or null if it was not found.
    <dt> <b>Throws:</b> <a href="java.lang.ClassNotFoundException.html#_top_">ClassNotFoundException</a>
    <dd> if the class loader cannot find
               a definition for the class.
    <dt> <b>See Also:</b>
    <dd> <a href="java.util.Hashtable.html#_top_">Hashtable</a>
  </dl></dd>
</dl>
<a name="defineClass(byte[], int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="defineClass"><b>defineClass</b></a>
<pre>
 protected final <a href="java.lang.Class.html#_top_">Class</a> defineClass(byte data[],
                                   int offset,
                                   int length)
</pre>
<dl>
<dd><b> Note: defineClass() is deprecated.</b>
<i>Replaced by defineClass(java.lang.String, byte[], int, int).</i>
<p>
  <dd> Converts an array of bytes into an instance of class 
 <code>Class</code>. 
 Before the Class can be used it must be resolved.  This
 method is deprecated in favor of the version that takes a
 "name" as a first argument, and is more secure.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> data - the bytes that make up the <code>Class</code>.
    <dd> offset - the start offset of the <code>Class</code> data.
    <dd> length - the length of the <code>Class</code> data.
    <dt> <b>Returns:</b>
    <dd> the <code>Class</code> object that was created from the data.
    <dt> <b>Throws:</b> <a href="java.lang.ClassFormatError.html#_top_">ClassFormatError</a>
    <dd> if the data does not contain a valid Class.
    <dt> <b>See Also:</b>
    <dd> <a href="#loadClass(java.lang.String, boolean)">loadClass</a>, <a href="#resolveClass(java.lang.Class)">resolveClass</a>
  </dl></dd>
</dl>
<a name="defineClass(java.lang.String, byte[], int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="defineClass"><b>defineClass</b></a>
<pre>
 protected final <a href="java.lang.Class.html#_top_">Class</a> defineClass(<a href="java.lang.String.html#_top_">String</a> name,
                                   byte data[],
                                   int offset,
                                   int length)
</pre>
<dl>
  <dd> Converts an array of bytes to an instance of class
 Class. Before the Class can be used it must be resolved.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> name - the expected name of the class; null if unknown;
                      using '.' and not '/' as separator, and without
                      a trailing ".class" suffix.
    <dd> data - the bytes that make up the <code>Class</code>.
    <dd> offset - the start offset of the <code>Class</code> data.
    <dd> length - the length of the <code>Class</code> data.
    <dt> <b>Returns:</b>
    <dd> the <code>Class</code> object that was created from the data.
    <dt> <b>Throws:</b> <a href="java.lang.ClassFormatError.html#_top_">ClassFormatError</a>
    <dd> if the data does not contain a valid Class.
    <dt> <b>See Also:</b>
    <dd> <a href="#loadClass(java.lang.String, boolean)">loadClass</a>, <a href="#resolveClass(java.lang.Class)">resolveClass</a>
  </dl></dd>
</dl>
<a name="resolveClass(java.lang.Class)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="resolveClass"><b>resolveClass</b></a>
<pre>
 protected final void resolveClass(<a href="java.lang.Class.html#_top_">Class</a> c)
</pre>
<dl>
  <dd> Resolves the class so that an instance of the class can be 
 created, or so that one of its methods can be called. This method 
 should be called by <code>loadClass</code> if the resolve flag is 
 <code>true</code>.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> c - the <code>Class</code> instance to be resolved.
    <dt> <b>See Also:</b>
    <dd> <a href="#defineClass(java.lang.String, byte[], int, int)">defineClass</a>
  </dl></dd>
</dl>
<a name="findSystemClass(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="findSystemClass"><b>findSystemClass</b></a>
<pre>
 protected final <a href="java.lang.Class.html#_top_">Class</a> findSystemClass(<a href="java.lang.String.html#_top_">String</a> name) throws <a href="java.lang.ClassNotFoundException.html#_top_">ClassNotFoundException</a>
</pre>
<dl>
  <dd> Finds the system class with the specified name, loading it in if 
 necessary. 
 <p>
 A system class is a class loaded from the local file system in a 
 platform- dependent way. It has no class loader.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> name - the name of the system <code>class</code>.
    <dt> <b>Returns:</b>
    <dd> a system class with the given name.
    <dt> <b>Throws:</b> <a href="java.lang.ClassNotFoundException.html#_top_">ClassNotFoundException</a>
    <dd> if it could not find a definition
               for the class.
    <dt> <b>Throws:</b> <a href="java.lang.NoClassDefFoundError.html#_top_">NoClassDefFoundError</a>
    <dd> if the class is not found.
  </dl></dd>
</dl>
<a name="setSigners(java.lang.Class, java.lang.Object[])"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setSigners"><b>setSigners</b></a>
<pre>
 protected final void setSigners(<a href="java.lang.Class.html#_top_">Class</a> cl,
                                 <a href="java.lang.Object.html#_top_">Object</a> signers[])
</pre>
<dl>
  <dd> Sets the signers of a class. This is called after defining a class,
 by signature-aware class loading code.
<p>
</dl>
<a name="findLoadedClass(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="findLoadedClass"><b>findLoadedClass</b></a>
<pre>
 protected final <a href="java.lang.Class.html#_top_">Class</a> findLoadedClass(<a href="java.lang.String.html#_top_">String</a> name)
</pre>
<dl>
</dl>
<a name="getSystemResourceAsStream(java.lang.String)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getSystemResourceAsStream"><b>getSystemResourceAsStream</b></a>
<pre>
 public static final <a href="java.io.InputStream.html#_top_">InputStream</a> getSystemResourceAsStream(<a href="java.lang.String.html#_top_">String</a> name)
</pre>
<dl>
  <dd> Get an InputStream on a given resource..  Will return null if no
 resource with this name is found. <p>
 The resource name may be any system resource (e.g. follows CLASSPATH
 order).
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> name - the name of the resource, to be used as is.
    <dt> <b>Returns:</b>
    <dd> an InputStream on the resource, or null if not found.
  </dl></dd>
</dl>
<a name="getSystemResource(java.lang.String)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getSystemResource"><b>getSystemResource</b></a>
<pre>
 public static final <a href="java.net.URL.html#_top_">URL</a> getSystemResource(<a href="java.lang.String.html#_top_">String</a> name)
</pre>
<dl>
  <dd> Find a resource with a given name.  The return is a URL to the resource
 Doing a getContent() on the URL may return an Image, an AudioClip, or
 an InputStream.<p>
 The resource name may be any system resource (e.g. follows CLASSPATH
 order).
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> name - the name of the resource, to be used as is.
    <dt> <b>Returns:</b>
    <dd> the URL on the resource, or null if not found.
  </dl></dd>
</dl>
<a name="getResourceAsStream(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getResourceAsStream"><b>getResourceAsStream</b></a>
<pre>
 public <a href="java.io.InputStream.html#_top_">InputStream</a> getResourceAsStream(<a href="java.lang.String.html#_top_">String</a> name)
</pre>
<dl>
  <dd> Get an InputStream on a given resource.  Will return null if no
 resource with this name is found. <p>
 The class loader can choose what to do to locate the resource.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> name - the name of the resource, to be used as is.
    <dt> <b>Returns:</b>
    <dd> an InputStream on the resource, or null if not found.
  </dl></dd>
</dl>
<a name="getResource(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getResource"><b>getResource</b></a>
<pre>
 public <a href="java.net.URL.html#_top_">URL</a> getResource(<a href="java.lang.String.html#_top_">String</a> name)
</pre>
<dl>
  <dd> Find a resource with a given name.  The return is a URL to the resource.
 Doing a getContent() on the URL may return an Image, an AudioClip,
 or an InputStream.<p>
 The class loader can choose what to do to locate the resource.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> name - the name of the resource, to be used as is.
    <dt> <b>Returns:</b>
    <dd> an InputStream on the resource, or null if not found.
  </dl></dd>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.lang.html">This Package</a>  <a href="java.lang.Class.html#_top_">Previous</a>  <a href="java.lang.Compiler.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
