The problem is in the output stream of the application. I imagine that your output is printed in
System.out while the output of the errors is being sent to
System.err . Being two different streams, the writing is not sequential. Then, consider that each of these streams must flushe the output to the same console, and again, it is not sequential, so the output looks strange.
To solve these problems, I recommend:
Use a single output stream. To do this, instead of using
error.printStackTrace() (which in your case is used automatically) you could use
Use a logging system such as log4j2 or logback. These frameworks contain the logic to redirect the output evenly to a single output stream.