Debugging a Java code depends on your IDE.
If you are using Eclipse or Netbeans, you will see line number at the beginning of the line. You can double click on the line and it will set a debug point.
After that, instead of Run, you should use debug command to debug your code.
If you are not using any IDE, you can use the log4j library to setup logs in every function and analyze the logs after the execution.