Reputation: 519
Hello after following the advice here Running JAR file on Windows, I've managed to execute my .jar
application whenever I double-click on it in Windows (it is a JFrame application).
However, when an certain exceptions occurs, I do e.printstackTrace();
and generate a custom error message to the UI. When I launch the '.jar' file from the command prompt, the standard error stream is the console. My question is, where does the exception trace go when I run the .jar via double-clicking?
This is a "toy" application, so I would like to avoid a logging mechanism - I only need a place to dump all exception traces for later debugging.
Thank you.
Upvotes: 2
Views: 562
Reputation: 1500575
My question is, where does the exception trace go when I run the .jar via double-clicking?
Nowhere. There's nowhere for it to go, basically - there's no console attached. You may want to find the user's home directory and put a log file there, or something like that.
(Rather than using e.printStackTrace()
, I'd suggest using a proper logging framework, whether that's log4j, java.util.logging or whatever. You say you don't want a logging mechanism, but "a place to dump all exception traces for later debugging" sounds like logging to me...)
Upvotes: 1
Reputation: 525
Your Exception stackTrace goes no where. There is nothing attached with it if you directly double click on jar.
The best way to dump all exception traces @ one one place is to use Logging API. Ex. Log4j, slf4j. They provide the proper framework, using that you can set the proper file name, their destination, what to place in that i.e. degug, error, warning; Moreover you can limit the file size and also decide its existance period.
Upvotes: 0