Class DirectoryClassLoader

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class DirectoryClassLoader
    extends URLClassLoader
    A class loader that loads classes from all jar files in a specified directory.
    • Constructor Detail

      • DirectoryClassLoader

        public DirectoryClassLoader​(String dir,
                                    ClassLoader parent)
                             throws IOException
        Create a DirectoryClassLoader to load from jar files in the specified directory, with the specified parent class loader.
        Parameters:
        dir - the directory of jar files to load from
        parent - the parent class loader
        Throws:
        IOException - if the directory can't be accessed
      • DirectoryClassLoader

        public DirectoryClassLoader​(File dir,
                                    ClassLoader parent)
                             throws IOException
        Create a DirectoryClassLoader to load from jar files in the specified directory, with the specified parent class loader.
        Parameters:
        dir - the directory of jar files to load from
        parent - the parent class loader
        Throws:
        IOException - if the directory can't be accessed