You can use an IDE (integrated development environment) with the Application Server to take advantage of the IDE's debugging features.
The following steps are applicable to the NetBeans 5 IDE and the Sun Java Studio 8 software, which is built on the NetBeans IDE.
Download the latest version of NetBeans from http://www.netbeans.org.
This site also provides documentation for the NetBeans IDE.
Start the NetBeans IDE.
If an Application Server is not already configured in the NetBeans IDE, perform the following steps:
Select the Runtime tab to display the Runtime window.
Right-click on Servers in the Runtime window.
Select the Add Server command from the menu.
On the first screen, select Sun Java System Application Server in the Server field, and type a name in the Name field. Select Next.
On the second screen, fill in the requested configuration information. In the Domains folder field, use the Browse button to go to the Application Server domain-root-dir directory.
Create a project (an application or module) in the NetBeans IDE.
Right-click on the project in the component tree and select Debug Project from the menu.
This stops the Application Server and restarts it in debug mode.
Set break points in your source file in the NetBeans IDE as usual, and run the application.