Class SystemJarFinder


  • public final class SystemJarFinder
    extends java.lang.Object
    A class to find rt.jar and any JRE "lib/" or "ext/" jars.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Set<java.lang.String> JRE_LIB_OR_EXT_JARS
      The paths of any "lib/" or "ext/" jars found in the JRE.
      private static java.lang.String RT_JAR
      The path of the first "rt.jar" found.
      private static java.util.Set<java.lang.String> RT_JARS
      The paths of any "rt.jar" files found in the JRE.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private SystemJarFinder()
      Constructor.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static boolean addJREPath​(java.io.File dir)
      Add and search a JRE path.
      static java.util.Set<java.lang.String> getJreLibOrExtJars()
      Get the JRE "lib/" and "ext/" jar paths.
      static java.lang.String getJreRtJarPath()
      Get the JRE "rt.jar" path.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • RT_JARS

        private static final java.util.Set<java.lang.String> RT_JARS
        The paths of any "rt.jar" files found in the JRE.
      • RT_JAR

        private static final java.lang.String RT_JAR
        The path of the first "rt.jar" found.
      • JRE_LIB_OR_EXT_JARS

        private static final java.util.Set<java.lang.String> JRE_LIB_OR_EXT_JARS
        The paths of any "lib/" or "ext/" jars found in the JRE.
    • Constructor Detail

      • SystemJarFinder

        private SystemJarFinder()
        Constructor.
    • Method Detail

      • addJREPath

        private static boolean addJREPath​(java.io.File dir)
        Add and search a JRE path.
        Parameters:
        dir - the JRE directory
        Returns:
        true if the directory was readable.
      • getJreRtJarPath

        public static java.lang.String getJreRtJarPath()
        Get the JRE "rt.jar" path.
        Returns:
        The path of rt.jar (in JDK 7 or 8), or null if it wasn't found (e.g. in JDK 9+).
      • getJreLibOrExtJars

        public static java.util.Set<java.lang.String> getJreLibOrExtJars()
        Get the JRE "lib/" and "ext/" jar paths.
        Returns:
        The paths for any jarfiles found in JRE/JDK "lib/" or "ext/" directories.