Class JarClassLoader

All Implemented Interfaces:
Closeable, AutoCloseable

public class JarClassLoader extends URLClassLoader
Utility class for assisting with loading Jar files into the classpath.
  • Constructor Details

    • JarClassLoader

      public JarClassLoader(ClassLoader parentClassLoader)
      Initialize a new JarClassLoader using a parent class loader.
      Parameters:
      parentClassLoader - The parent class loader to use
  • Method Details

    • addJarToClasspath

      public void addJarToClasspath(Path file) throws MalformedURLException
      Add a new Jar to the classpath.
      Parameters:
      file - The Jar file to add to the classpath
      Throws:
      MalformedURLException - If the file has an invalid URL
    • isJarInClassPath

      public boolean isJarInClassPath(Path file)
      Check if a Jar file is in the classpath.
      Parameters:
      file - The Jar file to check
      Returns:
      True if the Jar file is already in the classpath, false if otherwise