Can I reference compile time errors?

Posted on 2004-09-27
Last Modified: 2010-03-31
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: 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 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.
Question by:Breadstick
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 86

Expert Comment

ID: 12164188
You just need to capture the error stream of javac and put those in your errors area

Author Comment

ID: 12164611
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.
LVL 86

Expert Comment

ID: 12164712
Just capture it as a String then you can do what you want with it. Write the stream output to a StringWriter
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 12164850
> 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?
LVL 86

Accepted Solution

CEHJ earned 50 total points
ID: 12165012
Don't think so ;-)

Author Comment

ID: 12176311
Ouch, that stinks.  Do you know where I can find the documentation for then?
LVL 86

Expert Comment

ID: 12302529

Not easy to find that doco - Sun classes are 'undocumented'

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 64
Error in @AspectJ Based AOP with Spring 2 23
passing enum to a method 4 34
Java array sort 10 29
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question