<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FLanguage_Basics%2FClass_Loader</id>
		<title>Java/Language Basics/Class Loader - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FLanguage_Basics%2FClass_Loader"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Language_Basics/Class_Loader&amp;action=history"/>
		<updated>2026-04-22T05:44:47Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Language_Basics/Class_Loader&amp;diff=7499&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Language_Basics/Class_Loader&amp;diff=7499&amp;oldid=prev"/>
				<updated>2010-06-01T06:47:02Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:47, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Language_Basics/Class_Loader&amp;diff=7498&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Language_Basics/Class_Loader&amp;diff=7498&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:45Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Demonstration of a ClassLoader ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) Ian F. Darwin, http://www.darwinsys.ru/, 1996-2002.&lt;br /&gt;
 * All rights reserved. Software written by Ian F. Darwin and others.&lt;br /&gt;
 * $Id: LICENSE,v 1.8 2004/02/09 03:33:38 ian Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 * 1. Redistributions of source code must retain the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 * 2. Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *    documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS&amp;quot;&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED&lt;br /&gt;
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS&lt;br /&gt;
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;br /&gt;
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF&lt;br /&gt;
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;br /&gt;
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)&lt;br /&gt;
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 * &lt;br /&gt;
 * Java, the Duke mascot, and all variants of Sun&amp;quot;s Java &amp;quot;steaming coffee&lt;br /&gt;
 * cup&amp;quot; logo are trademarks of Sun Microsystems. Sun&amp;quot;s, and James Gosling&amp;quot;s,&lt;br /&gt;
 * pioneering role in inventing and promulgating (and standardizing) the Java &lt;br /&gt;
 * language and environment is gratefully acknowledged.&lt;br /&gt;
 * &lt;br /&gt;
 * The pioneering role of Dennis Ritchie and Bjarne Stroustrup, of AT&amp;amp;T, for&lt;br /&gt;
 * inventing predecessor languages C and C++ is also gratefully acknowledged.&lt;br /&gt;
 */&lt;br /&gt;
import java.lang.reflect.InvocationTargetException;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
/**&lt;br /&gt;
 * Demonstration of a ClassLoader&lt;br /&gt;
 */&lt;br /&gt;
public class ClassLoaderDemo1 extends ClassLoader {&lt;br /&gt;
  /** The Hashtable to keep track of classes, to avoid re-loading them */&lt;br /&gt;
  protected Hashtable cache = new Hashtable();&lt;br /&gt;
  /** data&amp;quot;s expected length */&lt;br /&gt;
  private final int dataLength = 433;&lt;br /&gt;
  /** data, obtained by dumping a compiled .class file */&lt;br /&gt;
  private int[] data = { 202, 254, 186, 190, 0, 3, 0, 45, 0, 31, 8, 0, 20, 7,&lt;br /&gt;
      0, 17, 7, 0, 25, 7, 0, 26, 7, 0, 27, 10, 0, 4, 0, 9, 9, 0, 5, 0,&lt;br /&gt;
      10, 10, 0, 3, 0, 11, 12, 0, 14, 0, 12, 12, 0, 28, 0, 22, 12, 0, 29,&lt;br /&gt;
      0, 13, 1, 0, 3, 40, 41, 86, 1, 0, 21, 40, 76, 106, 97, 118, 97, 47,&lt;br /&gt;
      108, 97, 110, 103, 47, 83, 116, 114, 105, 110, 103, 59, 41, 86, 1,&lt;br /&gt;
      0, 6, 60, 105, 110, 105, 116, 62, 1, 0, 4, 67, 111, 100, 101, 1, 0,&lt;br /&gt;
      13, 67, 111, 110, 115, 116, 97, 110, 116, 86, 97, 108, 117, 101, 1,&lt;br /&gt;
      0, 4, 68, 101, 109, 111, 1, 0, 9, 68, 101, 109, 111, 46, 106, 97,&lt;br /&gt;
      118, 97, 1, 0, 10, 69, 120, 99, 101, 112, 116, 105, 111, 110, 115,&lt;br /&gt;
      1, 0, 10, 72, 101, 108, 108, 111, 32, 74, 97, 118, 97, 1, 0, 15,&lt;br /&gt;
      76, 105, 110, 101, 78, 117, 109, 98, 101, 114, 84, 97, 98, 108,&lt;br /&gt;
      101, 1, 0, 21, 76, 106, 97, 118, 97, 47, 105, 111, 47, 80, 114,&lt;br /&gt;
      105, 110, 116, 83, 116, 114, 101, 97, 109, 59, 1, 0, 14, 76, 111,&lt;br /&gt;
      99, 97, 108, 86, 97, 114, 105, 97, 98, 108, 101, 115, 1, 0, 10, 83,&lt;br /&gt;
      111, 117, 114, 99, 101, 70, 105, 108, 101, 1, 0, 19, 106, 97, 118,&lt;br /&gt;
      97, 47, 105, 111, 47, 80, 114, 105, 110, 116, 83, 116, 114, 101,&lt;br /&gt;
      97, 109, 1, 0, 16, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 79,&lt;br /&gt;
      98, 106, 101, 99, 116, 1, 0, 16, 106, 97, 118, 97, 47, 108, 97,&lt;br /&gt;
      110, 103, 47, 83, 121, 115, 116, 101, 109, 1, 0, 3, 111, 117, 116,&lt;br /&gt;
      1, 0, 7, 112, 114, 105, 110, 116, 108, 110, 1, 0, 4, 116, 101, 115,&lt;br /&gt;
      116, 0, 33, 0, 2, 0, 4, 0, 0, 0, 0, 0, 2, 0, 9, 0, 30, 0, 12, 0, 1,&lt;br /&gt;
      0, 15, 0, 0, 0, 37, 0, 2, 0, 0, 0, 0, 0, 9, 178, 0, 7, 18, 1, 182,&lt;br /&gt;
      0, 8, 177, 0, 0, 0, 1, 0, 21, 0, 0, 0, 10, 0, 2, 0, 0, 0, 9, 0, 8,&lt;br /&gt;
      0, 8, 0, 1, 0, 14, 0, 12, 0, 1, 0, 15, 0, 0, 0, 29, 0, 1, 0, 1, 0,&lt;br /&gt;
      0, 0, 5, 42, 183, 0, 6, 177, 0, 0, 0, 1, 0, 21, 0, 0, 0, 6, 0, 1,&lt;br /&gt;
      0, 0, 0, 7, 0, 1, 0, 24, 0, 0, 0, 2, 0, 18 };&lt;br /&gt;
  /** &amp;quot;load&amp;quot;, that is, make up, the data for the class */&lt;br /&gt;
  private byte[] genClassData(String name) {&lt;br /&gt;
    if (dataLength != data.length)&lt;br /&gt;
      throw new IllegalArgumentException(&amp;quot;data corrupt&amp;quot;);&lt;br /&gt;
    byte[] bd = new byte[data.length];&lt;br /&gt;
    for (int i = 0; i &amp;lt; bd.length; i++)&lt;br /&gt;
      bd[i] = (byte) data[i];&lt;br /&gt;
    return bd;&lt;br /&gt;
  }&lt;br /&gt;
  public synchronized Class loadClass(String name, boolean resolve)&lt;br /&gt;
      throws ClassNotFoundException {&lt;br /&gt;
    /**&lt;br /&gt;
     * We can expect to be called to resolve at least demo&amp;quot;s superclass&lt;br /&gt;
     * (java.lang.Object). Fortunatetely, we can just use&lt;br /&gt;
     * super.findSystemClass() to load such things...&lt;br /&gt;
     */&lt;br /&gt;
    if (name.startsWith(&amp;quot;java.&amp;quot;)) {&lt;br /&gt;
      System.out.println(&amp;quot;loadClass: SystemLoading &amp;quot; + name);&lt;br /&gt;
      return findSystemClass(name);&lt;br /&gt;
    }&lt;br /&gt;
    Class c = (Class) cache.get(name);&lt;br /&gt;
    if (c == null) {&lt;br /&gt;
      System.out.println(&amp;quot;loadClass: About to genClassData &amp;quot; + name);&lt;br /&gt;
      byte mydata[] = genClassData(name);&lt;br /&gt;
      System.out.println(&amp;quot;loadClass: About to defineClass &amp;quot; + name);&lt;br /&gt;
      c = defineClass(name, mydata, 0, mydata.length);&lt;br /&gt;
      System.out.println(&amp;quot;loadClass: storing &amp;quot; + name + &amp;quot; in cache.&amp;quot;);&lt;br /&gt;
      cache.put(name, c);&lt;br /&gt;
    } else&lt;br /&gt;
      System.out.println(&amp;quot;loadClass: found &amp;quot; + name + &amp;quot; in cache.&amp;quot;);&lt;br /&gt;
    if (resolve) {&lt;br /&gt;
      System.out.println(&amp;quot;loadClass: About to resolveClass &amp;quot; + name);&lt;br /&gt;
      resolveClass(c);&lt;br /&gt;
    }&lt;br /&gt;
    return c;&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] argv) {&lt;br /&gt;
    System.out.println(&amp;quot;ClassLoaderDemo1 starting&amp;quot;);&lt;br /&gt;
    ClassLoaderDemo1 loader = new ClassLoaderDemo1();&lt;br /&gt;
    Class c = null;&lt;br /&gt;
    Object demo;&lt;br /&gt;
    try {&lt;br /&gt;
      /* Load the &amp;quot;Demo&amp;quot; class from memory */&lt;br /&gt;
      System.out.println(&amp;quot;About to load class  Demo&amp;quot;);&lt;br /&gt;
      c = loader.loadClass(&amp;quot;Demo&amp;quot;, true);&lt;br /&gt;
      System.out.println(&amp;quot;About to instantiate class Demo&amp;quot;);&lt;br /&gt;
      demo = c.newInstance();&lt;br /&gt;
      System.out.println(&amp;quot;Got Demo class loaded: &amp;quot; + demo);&lt;br /&gt;
      /* Now try to call a method */&lt;br /&gt;
      Method mi = c.getMethod(&amp;quot;test&amp;quot;, null);&lt;br /&gt;
      mi.invoke(demo, null);&lt;br /&gt;
    } catch (InvocationTargetException e) {&lt;br /&gt;
      // The invoked method threw an exception. We get it&lt;br /&gt;
      // wrapped up inside another exception, hence the&lt;br /&gt;
      // extra call here:&lt;br /&gt;
      e.getTargetException().printStackTrace();&lt;br /&gt;
      System.out.println(&amp;quot;Could not run test method&amp;quot;);&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
      System.out.println(&amp;quot;Could not run test method&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Try to load some arbitrary class, to see if our ClassLoader gets&lt;br /&gt;
     * called.&lt;br /&gt;
     */&lt;br /&gt;
    System.out.println(&amp;quot;Trying to load an unrelated class&amp;quot;);&lt;br /&gt;
    java.awt.image.DirectColorModel jnk = new java.awt.image.DirectColorModel(&lt;br /&gt;
        24, 8, 8, 8);&lt;br /&gt;
    System.out&lt;br /&gt;
        .println(&amp;quot;Load an unrelated class - was your ClassLoader called?&amp;quot;);&lt;br /&gt;
    /** Try to instantiate a second ClassLoader */&lt;br /&gt;
    System.out.println(&amp;quot;Trying to install another ClassLoader&amp;quot;);&lt;br /&gt;
    ClassLoaderDemo1 loader2 = new ClassLoaderDemo1();&lt;br /&gt;
    System.out.println(&amp;quot;Instantiated another ClassLoader...&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Runs a jar application from any url ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/* From http://java.sun.ru/docs/books/tutorial/index.html */&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 *&lt;br /&gt;
 * -Redistribution of source code must retain the above copyright notice, this&lt;br /&gt;
 *  list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 * -Redistribution in binary form must reproduce the above copyright notice,&lt;br /&gt;
 *  this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 *  and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * Neither the name of Sun Microsystems, Inc. or the names of contributors may&lt;br /&gt;
 * be used to endorse or promote products derived from this software without&lt;br /&gt;
 * specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. ALL&lt;br /&gt;
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING&lt;br /&gt;
 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE&lt;br /&gt;
 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. (&amp;quot;SUN&amp;quot;)&lt;br /&gt;
 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE&lt;br /&gt;
 * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS&lt;br /&gt;
 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST&lt;br /&gt;
 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,&lt;br /&gt;
 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY&lt;br /&gt;
 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,&lt;br /&gt;
 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 *&lt;br /&gt;
 * You acknowledge that this software is not designed, licensed or intended&lt;br /&gt;
 * for use in the design, construction, operation or maintenance of any&lt;br /&gt;
 * nuclear facility.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.lang.reflect.InvocationTargetException;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.lang.reflect.Modifier;&lt;br /&gt;
import java.net.JarURLConnection;&lt;br /&gt;
import java.net.MalformedURLException;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import java.net.URLClassLoader;&lt;br /&gt;
import java.util.jar.Attributes;&lt;br /&gt;
/**&lt;br /&gt;
 * Runs a jar application from any url. Usage is &amp;quot;java JarRunner url [args..]&amp;quot;&lt;br /&gt;
 * where url is the url of the jar file and args is optional arguments to be&lt;br /&gt;
 * passed to the application&amp;quot;s main method.&lt;br /&gt;
 */&lt;br /&gt;
public class JarRunner {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    if (args.length &amp;lt; 1) {&lt;br /&gt;
      usage();&lt;br /&gt;
    }&lt;br /&gt;
    URL url = null;&lt;br /&gt;
    try {&lt;br /&gt;
      url = new URL(args[0]);&lt;br /&gt;
    } catch (MalformedURLException e) {&lt;br /&gt;
      fatal(&amp;quot;Invalid URL: &amp;quot; + args[0]);&lt;br /&gt;
    }&lt;br /&gt;
    // Create the class loader for the application jar file&lt;br /&gt;
    JarClassLoader cl = new JarClassLoader(url);&lt;br /&gt;
    // Get the application&amp;quot;s main class name&lt;br /&gt;
    String name = null;&lt;br /&gt;
    try {&lt;br /&gt;
      name = cl.getMainClassName();&lt;br /&gt;
    } catch (IOException e) {&lt;br /&gt;
      System.err.println(&amp;quot;I/O error while loading JAR file:&amp;quot;);&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
      System.exit(1);&lt;br /&gt;
    }&lt;br /&gt;
    if (name == null) {&lt;br /&gt;
      fatal(&amp;quot;Specified jar file does not contain a &amp;quot;Main-Class&amp;quot;&amp;quot;&lt;br /&gt;
          + &amp;quot; manifest attribute&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    // Get arguments for the application&lt;br /&gt;
    String[] newArgs = new String[args.length - 1];&lt;br /&gt;
    System.arraycopy(args, 1, newArgs, 0, newArgs.length);&lt;br /&gt;
    // Invoke application&amp;quot;s main class&lt;br /&gt;
    try {&lt;br /&gt;
      cl.invokeClass(name, newArgs);&lt;br /&gt;
    } catch (ClassNotFoundException e) {&lt;br /&gt;
      fatal(&amp;quot;Class not found: &amp;quot; + name);&lt;br /&gt;
    } catch (NoSuchMethodException e) {&lt;br /&gt;
      fatal(&amp;quot;Class does not define a &amp;quot;main&amp;quot; method: &amp;quot; + name);&lt;br /&gt;
    } catch (InvocationTargetException e) {&lt;br /&gt;
      e.getTargetException().printStackTrace();&lt;br /&gt;
      System.exit(1);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private static void fatal(String s) {&lt;br /&gt;
    System.err.println(s);&lt;br /&gt;
    System.exit(1);&lt;br /&gt;
  }&lt;br /&gt;
  private static void usage() {&lt;br /&gt;
    fatal(&amp;quot;Usage: java JarRunner url [args..]&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/**&lt;br /&gt;
 * A class loader for loading jar files, both local and remote.&lt;br /&gt;
 */&lt;br /&gt;
class JarClassLoader extends URLClassLoader {&lt;br /&gt;
  private URL url;&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates a new JarClassLoader for the specified url.&lt;br /&gt;
   * &lt;br /&gt;
   * @param url&lt;br /&gt;
   *            the url of the jar file&lt;br /&gt;
   */&lt;br /&gt;
  public JarClassLoader(URL url) {&lt;br /&gt;
    super(new URL[] { url });&lt;br /&gt;
    this.url = url;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the name of the jar file main class, or null if no &amp;quot;Main-Class&amp;quot;&lt;br /&gt;
   * manifest attributes was defined.&lt;br /&gt;
   */&lt;br /&gt;
  public String getMainClassName() throws IOException {&lt;br /&gt;
    URL u = new URL(&amp;quot;jar&amp;quot;, &amp;quot;&amp;quot;, url + &amp;quot;!/&amp;quot;);&lt;br /&gt;
    JarURLConnection uc = (JarURLConnection) u.openConnection();&lt;br /&gt;
    Attributes attr = uc.getMainAttributes();&lt;br /&gt;
    return attr != null ? attr.getValue(Attributes.Name.MAIN_CLASS) : null;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Invokes the application in this jar file given the name of the main class&lt;br /&gt;
   * and an array of arguments. The class must define a static method &amp;quot;main&amp;quot;&lt;br /&gt;
   * which takes an array of String arguemtns and is of return type &amp;quot;void&amp;quot;.&lt;br /&gt;
   * &lt;br /&gt;
   * @param name&lt;br /&gt;
   *            the name of the main class&lt;br /&gt;
   * @param args&lt;br /&gt;
   *            the arguments for the application&lt;br /&gt;
   * @exception ClassNotFoundException&lt;br /&gt;
   *                if the specified class could not be found&lt;br /&gt;
   * @exception NoSuchMethodException&lt;br /&gt;
   *                if the specified class does not contain a &amp;quot;main&amp;quot; method&lt;br /&gt;
   * @exception InvocationTargetException&lt;br /&gt;
   *                if the application raised an exception&lt;br /&gt;
   */&lt;br /&gt;
  public void invokeClass(String name, String[] args)&lt;br /&gt;
      throws ClassNotFoundException, NoSuchMethodException,&lt;br /&gt;
      InvocationTargetException {&lt;br /&gt;
    Class c = loadClass(name);&lt;br /&gt;
    Method m = c.getMethod(&amp;quot;main&amp;quot;, new Class[] { args.getClass() });&lt;br /&gt;
    m.setAccessible(true);&lt;br /&gt;
    int mods = m.getModifiers();&lt;br /&gt;
    if (m.getReturnType() != void.class || !Modifier.isStatic(mods)&lt;br /&gt;
        || !Modifier.isPublic(mods)) {&lt;br /&gt;
      throw new NoSuchMethodException(&amp;quot;main&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    try {&lt;br /&gt;
      m.invoke(null, new Object[] { args });&lt;br /&gt;
    } catch (IllegalAccessException e) {&lt;br /&gt;
      // This should not happen, as we have disabled access checks&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>