Class MainClassFinder
java.lang.Object
org.springframework.boot.loader.tools.MainClassFinder
Finds any class with a 
public static main method by performing a breadth first
 search.- Since:
- 1.0.0
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic StringfindMainClass(File rootDirectory) Find the main class from a given directory.static StringfindMainClass(JarFile jarFile, String classesLocation) Find the main class in a given jar file.static StringfindSingleMainClass(File rootDirectory) Find a single main class from the givenrootDirectory.static StringfindSingleMainClass(File rootDirectory, String annotationName) Find a single main class from the givenrootDirectory.static StringfindSingleMainClass(JarFile jarFile, String classesLocation) Find a single main class in a given jar file.static StringfindSingleMainClass(JarFile jarFile, String classesLocation, String annotationName) Find a single main class in a given jar file.
- 
Constructor Details- 
MainClassFinderpublic MainClassFinder()
 
- 
- 
Method Details- 
findMainClassFind the main class from a given directory.- Parameters:
- rootDirectory- the root directory to search
- Returns:
- the main class or null
- Throws:
- IOException- if the directory cannot be read
 
- 
findSingleMainClassFind a single main class from the givenrootDirectory.- Parameters:
- rootDirectory- the root directory to search
- Returns:
- the main class or null
- Throws:
- IOException- if the directory cannot be read
 
- 
findSingleMainClasspublic static String findSingleMainClass(File rootDirectory, String annotationName) throws IOException Find a single main class from the givenrootDirectory. A main class annotated with an annotation with the givenannotationNamewill be preferred over a main class with no such annotation.- Parameters:
- rootDirectory- the root directory to search
- annotationName- the name of the annotation that may be present on the main class
- Returns:
- the main class or null
- Throws:
- IOException- if the directory cannot be read
 
- 
findMainClassFind the main class in a given jar file.- Parameters:
- jarFile- the jar file to search
- classesLocation- the location within the jar containing classes
- Returns:
- the main class or null
- Throws:
- IOException- if the jar file cannot be read
 
- 
findSingleMainClasspublic static String findSingleMainClass(JarFile jarFile, String classesLocation) throws IOException Find a single main class in a given jar file.- Parameters:
- jarFile- the jar file to search
- classesLocation- the location within the jar containing classes
- Returns:
- the main class or null
- Throws:
- IOException- if the jar file cannot be read
 
- 
findSingleMainClasspublic 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 givenannotationNamewill be preferred over a main class with no such annotation.- Parameters:
- 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
- Returns:
- the main class or null
- Throws:
- IOException- if the jar file cannot be read
 
 
-