Question

I'd be interested to know whether it's possible to run javac or an equivalent tool to just analyze the given Java source code without actually generating any code.

The usefulness would lie in being able to verify whether my Java code is correct without having to generate any .class output files.

Thanks

Was it helpful?

Solution

Yes, there is. I have never tried it, so I can not verify that this actually works, but ...

javac -proc:only

means that only annotation processing is done, without any subsequent compilation.

If that did not work, what is wrong with just using

javac -d /dev/null

OTHER TIPS

You may be interested in the Java Tools API. This API gives you programmatic control over the Java compiler and you can pretty much write a program to read and analyze a Java program. The API docs give an example of compiling a list of compiler error messages.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top