Skip to content
Advertisement

Tag: error-handling

Printing stack trace in JOptionPane

My question: How can i put the text e.printStackTrace prints into a JOptionPane window My code is currently as follows: excuse the poor formatting 😛 this both prints the stack trace in the command line interface(i am using terminal) and it creates a JOptionPane but NOT with the same info as e.printStackTrace(). when running my program from a jar file,

Does a finally block always get executed in Java?

Considering this code, can I be absolutely sure that the finally block always executes, no matter what something() is? Answer Yes, finally will be called after the execution of the try or catch code blocks. The only times finally won’t be called are: If you invoke System.exit() If you invoke Runtime.getRuntime().halt(exitStatus) If the JVM crashes first If the JVM reaches

Advertisement