类 MainClassFinder


  • public abstract class MainClassFinder
    extends Object
    Finds any class with a public static main method by performing a breadth first search.
    • 方法详细资料

      • findMainClass

        public static String findMainClass​(File rootFolder)
                                    throws IOException
        Find the main class from a given folder.
        参数:
        rootFolder - the root folder to search
        返回:
        the main class or null
        抛出:
        IOException - if the folder cannot be read
      • findSingleMainClass

        public static String findSingleMainClass​(File rootFolder)
                                          throws IOException
        Find a single main class from the given rootFolder.
        参数:
        rootFolder - the root folder to search
        返回:
        the main class or null
        抛出:
        IOException - if the folder cannot be read
      • findSingleMainClass

        public static String findSingleMainClass​(File rootFolder,
                                                 String annotationName)
                                          throws IOException
        Find a single main class from the given rootFolder. A main class annotated with an annotation with the given annotationName will be preferred over a main class with no such annotation.
        参数:
        rootFolder - the root folder to search
        annotationName - the name of the annotation that may be present on the main class
        返回:
        the main class or null
        抛出:
        IOException - if the folder cannot be read
      • findSingleMainClass

        public static String findSingleMainClass​(Collection<File> rootFolders,
                                                 String annotationName)
                                          throws IOException
        Find a single main class from the given rootFolders. A main class annotated with an annotation with the given annotationName will be preferred over a main class with no such annotation.
        参数:
        rootFolders - the root folders to search
        annotationName - the name of the annotation that may be present on the main class
        返回:
        the main class or null
        抛出:
        IOException - if a root folder cannot be read
        从以下版本开始:
        1.5.5
      • findMainClass

        public static String findMainClass​(JarFile jarFile,
                                           String classesLocation)
                                    throws IOException
        Find the main class in a given jar file.
        参数:
        jarFile - the jar file to search
        classesLocation - the location within the jar containing classes
        返回:
        the main class or null
        抛出:
        IOException - if the jar file cannot be read
      • findSingleMainClass

        public static String findSingleMainClass​(JarFile jarFile,
                                                 String classesLocation)
                                          throws IOException
        Find a single main class in a given jar file.
        参数:
        jarFile - the jar file to search
        classesLocation - the location within the jar containing classes
        返回:
        the main class or null
        抛出:
        IOException - if the jar file cannot be read
      • findSingleMainClass

        public static String findSingleMainClass​(JarFile jarFile,
                                                 String classesLocation,
                                                 String annotationName)
                                          throws IOException
        Find a single main class in a given jar file. A main class annotated with an annotation with the given annotationName will be preferred over a main class with no such annotation.
        参数:
        jarFile - the jar file to search
        classesLocation - the location within the jar containing classes
        annotationName - the name of the annotation that may be present on the main class
        返回:
        the main class or null
        抛出:
        IOException - if the jar file cannot be read