Compiling a Java File Set in a Directory Tree Using the JSR 199 Compiler API

I am trying to compile many files using the compiler API.

Say I have a directory structure

.../program
   +/org
    +/foo
    |+ Main.java
    +/bar
     + Tools.java

Is there a way to detect all Java files and make it all a compiler, without resorting to recursion to all directories and finding all * .java files?

EDIT: What I'm trying to do is compile all the classes that I get in any directory tree. These classes are independent of each other. Then I load the classes and instantiate some objects of these classes and call the methods. None of the classes should have a core.

+3
source share
1 answer

javax.tools.JavaFileManager list(), :

Iterable<JavaFileObject> list(JavaFileManager.Location location,
                              String packageName,
                              Set<JavaFileObject.Kind> kinds,
                              boolean recurse)
                              throws IOException

recurse, "", JavaFileObject.

+3

Source: https://habr.com/ru/post/1720254/


All Articles