How do I get full exception message in Java?
I am creating a Java Application. If there is a runtime exception, a JDialog
with a JTextArea
if you are not using any logger(Log4j or oracle logger api) then you can use the below statement to print the full exception message
try{
// statement which you want to monitor
}catch(Exception e){
e.printStackTrace()
// OR System.err.println(e.getStackTrace());
// OR System.err.println(e);
// OR System.err.println(e.getMessage());
// OR System.err.println(e.getCause());
}
if you are using the Logger API then use the below statement
try{
// statement which you want to monitor
}catch(Exception e){
log.error(e,e);
}