com.edsdev.jconvert.util
Class JCClassLoader

java.lang.Object
  extended byjava.lang.ClassLoader
      extended bycom.edsdev.jconvert.util.JCClassLoader

public class JCClassLoader
extends java.lang.ClassLoader

Used to load classes that are not in the classpath, by loading them from a specific directory/jar file. The class will be loaded from the default classloaders first if possible, so do not use this mechanism to somehow override existing classes that are in the classpath. This is a wrapper around java.net.URLClassLoader and only provides convienince, sinplicity, safety, better exception processing, and better exception messages.
Example of use:

 
       ClassLoader loader = new JCClassLoader("i:/somepath/myjar-1.0.6.jar");
       Object main = loader.loadClass("com.mydomain.myproject.MyClass").newInstance();
       
       ClassLoader fileLoader = new JCClassLoader("i:/temp/");
       Object temp = fileLoader.loadClass("com.test.MyTestClass").newInstance()
  
 

Author:
Ed Sarrazin Created on Nov 2, 2007 5:00:57 PM

Constructor Summary
JCClassLoader(java.lang.String pPath)
          Constructs this class loader with the specified path.
 
Method Summary
protected  java.lang.Class findClass(java.lang.String className)
           
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCClassLoader

public JCClassLoader(java.lang.String pPath)
Constructs this class loader with the specified path. This path can be a directory (c:/test/), or it can be a path to a jar file (c:/test/myjar.jar). Nulls will be transfrmed to an empty string.

Parameters:
pPath - String representation of the directory or jar file
Method Detail

findClass

protected java.lang.Class findClass(java.lang.String className)
                             throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException


JConvert - opensource project by Ed Sarrazin