Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

Can I reference compile time errors?

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
     myLabel.setPrefferedSize(new Dimension(400,250));
             ^1 error

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.
0
Breadstick
Asked:
Breadstick
  • 4
  • 3
1 Solution
 
CEHJCommented:
You just need to capture the error stream of javac and put those in your errors area
0
 
BreadstickAuthor Commented:
Maybe I wasn't clear.  I can capture the error stream fine, but I don't want to display the errors as javac would display them.  I haven't used an IDE that simply outputs the error in the same format as you would get from javac.  They all display them in an easy to read format, usually one line per error, and usually in a list or tree.
0
 
CEHJCommented:
Just capture it as a String then you can do what you want with it. Write the stream output to a StringWriter
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
BreadstickAuthor Commented:
> I really don't want to have to go and do a bunch of string parsing on what javac gave me  :P

Is there any other way?
0
 
CEHJCommented:
Don't think so ;-)
0
 
BreadstickAuthor Commented:
Ouch, that stinks.  Do you know where I can find the documentation for com.sun.tools.javac.Main then?
0
 
CEHJCommented:
8-)

Not easy to find that doco - Sun classes are 'undocumented'
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now