JExceptionReporter shows short or detail exception report in graphical user interface. Generally we show the Java exception stack trace in console by calling printStackTrace method. If you want to show the stack trace in graphical mode, you can use the JExceptionReporter.
Just call the showExceptionReport method of JExceptionReporter giving the Exception object in your catch block like below:
try
{
double number1=Double.parseDouble(txtFirstNumber.getText());
double number2=Double.parseDouble(txtSecondNumber.getText());
txtResult.setText(String.valueOf(number1/number2));
}
catch(NumberFormatException nfe)
{
JExceptionReporter.showExceptionReport(nfe);
}
catch(ArithmeticException ae)
{
JExceptionReporter.showExceptionReport(ae);
}
Then you will see the following output if any exception occurs in runtime.
Initially it will show the short message (what exception occurred) only but it will show the details stack trace if you click ‘Show Details’ button. Again you can shorten it by clicking the ‘Hide Details’ button.
Downloads:
Executable Jar File : JExceptionReporter.jar
NetBeans Project : JExceptionReporter.zip
Individual Java Source File : JExceptionReporter.java , TestJExceptionReporter.java
Google Plugin for Eclipse (GPE) is Now Open Source
-
Google Plugin for Eclipse (GPE) is Now Open Source:
"Today is quite a milestone for the Google Plugin for Eclipse (GPE). Our
team is very happy to announce...
3 months ago
0 comments:
Post a Comment