2

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.

Community
  • 1
  • 1
user1485864
  • 499
  • 6
  • 18

2 Answers2

1

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...)

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • Thank you for your answer. I want to avoid using logging for an application that is 300 lines of code (100 are auto-generated) and represent half a day of work. But I like the idea of using the user's home directory. If I don't run into weird permission problems, that should do the trick. Thanks! – user1485864 Oct 10 '12 at 19:21
0

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.

Ravi A
  • 505
  • 1
  • 5
  • 16
  • Thank you for your answer. Given that my program is 300 lines of code, I guess the simplest/ fastest way would be to use the user's home directory as Jon Skeet suggested in his reply below. Thanks again. – user1485864 Oct 10 '12 at 19:24