Solved

Can I reference compile time errors?

Posted on 2004-09-27
7
156 Views
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:

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
Comment
Question by:Breadstick
  • 4
  • 3
7 Comments
 
LVL 86

Expert Comment

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

Author Comment

by:Breadstick
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.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12164712
Just capture it as a String then you can do what you want with it. Write the stream output to a StringWriter
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Author Comment

by:Breadstick
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?
0
 
LVL 86

Accepted Solution

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

Author Comment

by:Breadstick
ID: 12176311
Ouch, that stinks.  Do you know where I can find the documentation for com.sun.tools.javac.Main then?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12302529
8-)

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groovy example issue 10 90
what is the difference between "sudo su" and "su - root" 6 107
xampp tool 12 31
hibernate jars 4 9
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now