Can I reference compile time errors?
Posted on 2004-09-27
I'm working on a small IDE for personal use, but I'm having trouble with error handling. I'm using Runtime.getRuntime().exec( ... ) to compile and run java programs. Ultimately telling the system to execute javac. Also, I'm using a class called RunProcess to redirect stdout and stderr to a JTextArea (my error log window).
When a runtime exception occurs, I'm simply logging the error to the JTextArea as it would be output to the console. However, when a compile time errors occur, I would like to display the errors in an organized tree, rather than the format that it would have been outputed to the console, which would look something like this:
Test.java:12: cannot resolve symbol
symbol : method setPrefferedSize(java.awt.Dimension)
location : class javax.swing.JLabel
Is there a way to get a reference to some sort of StackTrace, or Exception that I can use to represent this error? I really don't want to have to go and do a bunch of string parsing on what javac gave me :P
Is it perhaps possible using another method of compiling? Such as using the com.sun.tools.javac.Main tool, and javac() to compile? I can't find the documentation for that class anywhere, so I can't figure it out. I can just find code snippits around the web.
Thanks, and I hope that wasn't too confusing.