Is it possible to view which class files will be generated by the Java compiler?

Is there an option for javac

, say --dry-run

, which instructs the compiler not to actually compile, but to parse the source file and a list of files .class

(including the package path) will be generated?

Consider the following example:

$ cat example.java
package whatever.example;
class First {}
class Second {}
$ javac -d . example.java
$ find .
.
./example.java
./whatever
./whatever/example
./whatever/example/First.class
./whatever/example/Second.class

      

The source file was compiled into two files .class

, and because the option was specified -d

, the package structure was created. I would like to know such information before compiling. Something like that:

$ javac --dry-run -d . example.java
./whatever/example/First.class
./whatever/example/Second.class

      

Alternatively, if javac

there is no such option for , is there any third party utility that can do this?

+3


source to share


1 answer


try it

javac -verbose -d . javaclass.java

      

it actually lists all the activities the compiler is working on. by the end you can that all the classes were created using the package structure.

I have a compiler using the above code. I am getting the following result at the end of the list.



[wrote RegularFileObject[.\com\SC\JustTesting.class]]
[wrote RegularFileObject[.\com\SC\JustTestingSecond.class]]

      

There are many other options, just type javac

in the command line to see them.

I don't know if I can know, before compiling, this information.

+2


source







All Articles