classUtils.loaders
Class JarClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by classUtils.loaders.JarClassLoader

public class JarClassLoader
extends java.net.URLClassLoader

A class loader for loading jar files, both local and remote.


Constructor Summary
JarClassLoader(java.net.URL url)
          Creates a new JarClassLoader for the specified url.
 
Method Summary
 java.lang.String getMainClassName()
          Returns the name of the jar file main class, or null if no "Main-Class" manifest attributes was defined.
 void invokeClass(java.lang.String name, java.lang.String[] args)
          Invokes the application in this jar file given the name of the main class and an array of arguments.
 
Methods inherited from class java.net.URLClassLoader
findResource, findResources, getURLs, newInstance, newInstance
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JarClassLoader

public JarClassLoader(java.net.URL url)
Creates a new JarClassLoader for the specified url.

Parameters:
url - the url of the jar file
Method Detail

getMainClassName

public java.lang.String getMainClassName()
                                  throws java.io.IOException
Returns the name of the jar file main class, or null if no "Main-Class" manifest attributes was defined.

Throws:
java.io.IOException

invokeClass

public void invokeClass(java.lang.String name,
                        java.lang.String[] args)
                 throws java.lang.ClassNotFoundException,
                        java.lang.NoSuchMethodException,
                        java.lang.reflect.InvocationTargetException
Invokes the application in this jar file given the name of the main class and an array of arguments. The class must define a static method "main" which takes an array of String arguemtns and is of return type "void".

Parameters:
name - the name of the main class
args - the arguments for the application
Throws:
java.lang.ClassNotFoundException - if the specified class could not be found
java.lang.NoSuchMethodException - if the specified class does not contain a "main" method
java.lang.reflect.InvocationTargetException - if the application raised an exception