Skip to content
Advertisement

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 😛

JavaScript

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, the command line interface won’t be visible so the user will only get the JOptionPane window which doesnt have all of the info i need to succesfully identify the problem

Thanks in advance 🙂

Advertisement

Answer

Here, This is just some general code I came up with that will get you the same output as e.printStackTrace().

JavaScript

However, as was previously mentioned, you probably want a window in which you can scroll, as I don’t think it’d fit very well in a JOptionPane.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement