How to debug a running jar when an accident does not occur in the debugger?

When I debug a game in an eclipse, the game works great. However, when I make a running can of it, the game crashes when the enemy hits the target, the rest of the game works fine, except for that part. What should I do, how can I debug a runnable jar?

+4
source share
3 answers

Place a try / catch around the function the enemy hits. In the statement, you can print a stack trace and exception information.

Sort of:

try { enemyHit(); } catch (Exception e) { System.out.print("RuntimeException: "); System.out.println(e.getMessage()); e.printStackTrace(); } 

Run the jar from the command line so that printouts are still present when the ATM fails. Also, write the error information to a file.

You can push try / catch further on the stack if it doesn't catch anything. If you don't catch the exceptions elsewhere, you can put this attempt in the full path at the top of your stack around your main loop.

I would not recommend keeping try / catch in your release code if you are sure that the error has been resolved. There are performance issues related to try / catch that will slow down your game if you have surrounding frequently used functions.

+6
source

create a new project and add an executable jar to external banks, and then using the launch configurations you can select its main method and debug from there

you can also set the source jar folder to the source folder of another project (just remember that replacing the hot code no longer works)

+1
source

when I had a problem similar to what you see, it takes a little extra time to the debugger (especially with break points), and then a compiled program.

this problem occurred when I tried to load the texture asynchronously, it will work fine in the debugger, but the compilation fails, I will look at any thread (if any) or any other longer work item

0
source

All Articles