Class Jars


  • public class Jars
    extends Object
    Utilities for working with Java JAR files.
    • Constructor Detail

      • Jars

        public Jars()
    • Method Detail

      • getPathComponents

        public static List<String> getPathComponents​(Class<?> classInJar)
        Get the path components of the JAR file path that the given class lives in, or an empty list if the path components could not be obtained.
        Parameters:
        classInJar - the class which resides in the JAR you want to find
        Returns:
        a mutable list of path components if found, or an immutable empty list if not found or an exception is thrown attempting to get the path
      • getPath

        public static Optional<String> getPath​(Class<?> classInJar)
        Get the path of the JAR file that the given class lives in, or an empty Optional if the path could not be obtained for any reason.
        Parameters:
        classInJar - the class which resides in the JAR you want to find
        Returns:
        optional containing the path if found, or an empty optional
      • getDirectoryPath

        public static Optional<String> getDirectoryPath​(Class<?> classInJar)
        Get the directory path of the JAR file that the given class lives in, or an empty Optional if the path could not be obtained for any reason.
        Parameters:
        classInJar - the class which resides in the JAR you want to find
        Returns:
        optional containing the directory path if found, or an empty optional