---from Attaching a debugger to a Java Applet
I had to do this the other day, so I thought I’d pop it here for reference.
First of all, set up the Java plugin, via the Control Panel in Windows. For the JDK 1.3 plugin, navigate to the basic tab, and enter these settings in the runtime parameters box:
-Djava.compiler=NONE -Xnoagent -Xdebug -Xrunjdwp:transport=dt_socket,address=2502,server=y,suspend=n
The ‘dt_socket’ parameter here sets up a TCP port for a debugger to attach to. The 2502 can be any TCP port you like.
For JDK 1.5, its a bit different, select the Java tab in the control panel applet, and click on ‘View’. Enter the above settings in the Java runtime parameters cell.
Navigate to the page with your applet in your browser. You should now be able to attach a debugger.
I use Eclipse as my Java IDE, but this should work in the likes of Netbeans and IntelliJ IDEA as well.
First of all, set some breakpoints in your application, else you won’t have much to debug
In Eclipse, select ‘Run’ and then ‘Debug…’. Create a new ‘Remote Java Application’. Select the TCP port you entered above (2502).
Add the source for your project on the source tab.
Click the debug button and away you go.