If you’ve created a Java console application and noticed peculiar behavior when it runs, these procedures will help you debug your application.
Note The application example for this scenario was built in Creating a Console Application. If you’d like to create this project to complete the following exercises, do so now.
The application in this scenario accepts a calendar date passed from the command line and converts it to a Julian date. Once the date’s been entered, you’ll set a breakpoint and start debugging the application. You’ll also examine the value of some member variables with the debug windows. Although there may be references to specific code statements in the Julian Date Conversion application, you can substitute code and member variables from any application and still find the procedures in this scenario helpful.
Running the application requires that a date be entered from the command line before this program runs. The steps in the procedure for Entering Command-line Arguments shows you how to pass this information to the application from the development environment’s Launch tab. After you’ve entered command-line arguments for your program, go to Setting a Breakpoint Before Starting the Debugger to begin the debugging session.
When execution of your application stops on a break point, view current values for your application’s member variables in the Auto, Locals, Watch, and Immediate debug windows. This gives you a snapshot of what’s happening with your program up to the place where it entered break mode.
Now that you’ve had a chance look at the state of your program up to where it entered break mode, you may want to set another breakpoint, and then continue Stepping Through the Code.
This concludes the scenario for debugging a console application using the Julian Date Conversion application. See Basic Debugging Procedures for additional information on using the features of the integrated debugger.