You don't need to Runtime.exec the compiler. I know ant doesn't do this... Looking at the ant source code, it looks like they use a class names "sun.tools.javac.Main", so if you can find that (again, the ant src distro would help here), you can do it
Joined: Jan 30, 2002
Hi John, That is a good point. Most of us tend to forget about the propriatery packages that are available to us since there is usually not a published API nor any guarantee that they will remain as is. But I'm sure your method would work fine. Michael Morris
Check Rodey Green's Java Glossary entry on javac - under the table of command line switches he gives a usage example. This class is in JAVA_HOME/lib/tools.jar, so you have to include that in CLASSPATH to use it from a program. As I recall, the main() method is used from javac.exe, but it does a System.exit() - so you don't want to do that from your program. Use the compile() method which returns a boolean for success/fail.