[All]
Remote Debugging: Attaching to existing processes using the JBuilder 3.5 Enterprise or JBuilder 3 Enterprise - Solaris Edition debugger.
By: Josh Fletcher
Abstract: How to attach the JBuilder 3 Enterprise - Solaris Edition or JBuilder 3.5 Enterprise debugger to an existing Java process (including some undocumented features).
|
Question:
|
|
I am using JBuilder 3 Enterpise - Solaris Edition or JBuilder 3.5 Enterprise and I can't get Remote Debugging to attach to an existing process. Why is this?
|
| |
|
Answer:
|
|
There are some command line switches that were accidentally left out of the documentation that will help with this. A model command line to launch a process in debug mode so that a process can attach to it is as follows:
java -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=xxxx,suspend=n -classpath <CLASSPATH> <MyClass>
The address works like a port number, so the JBuilder debugger has some kind of ID to use to attach to the process. You can hard code this in the command line if you like. If you leave the address off then you will need to get it from the JVM at run-time.
The suspend option tells the JVM whether or not to suspend the process to wait for the debugger to attach. The default is suspend=y. It is recommended that you set it to suspend=n.
Here's an example of how to use this:
- Launch a process, on say "MyClass1", from a command shell using a command line like the one above (specify the address as something like "1243").
- In JBuilder, open the Project Properties and select the Debug tab.
- Click "Enable Remote Debugging" and select the Attach tab.
- Fill in the required fields. They should match what you used in your command line.
- Click Ok to save the changes.
At this point, you should have your class ("MyClass1") running in a separate process. Select the .java file for this class ("MyClass1.java") in the IDE, right-click on it, and select Debug. Now the debugger will launch and attach itself to the already existing process running your class.
Note that Remote Debugging is now enabled for the whole project. You will have to turn it off in order to debug normally. A new feature that allows you to have multiple debugging profiles should appear in a future release of JBuilder.
|
| |