I am trying to configure Visual Studio Code so that I can use it instead of IJ for debugging a complex Java app. Because of reasons too complicated to get into, I have been running on a terminal using mvnDebug then connecting using JDB. In IJ I set this up as a remote debugger, however, I can't seem to find the same option in VSC.
I have tried this extension, but I can't figure out how to configure it for just JDB (I shouldn't need startupClass etc).
How do I use JDB with Visual Studio Code?
To perform remote debugging using Visual Studio: On the remote computer, in Visual Studio, choose Connect to Remote Debugger from the Tools menu. In the Connect to Remote Debugger dialog box, enter a connection string, and click Connect.
In Visual Studio Code, open the Extensions view (Ctrl+Shift+X). Type "java" to filter the list. Find and install the Extension Pack for Java or standalone Debugger for Java extension if you already have Language Support for Java™ by Red Hat installed.
Connect to a remote host#In VS Code, select Remote-SSH: Connect to Host... from the Command Palette (F1, Ctrl+Shift+P) and use the same user@hostname as in step 1. If VS Code cannot automatically detect the type of server you are connecting to, you will be asked to select the type manually.
Create a Debug Configuration like below and press F5 to debug :
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Attach)",
"projectName": "Your_Project_Name",
"request": "attach",
"hostName": "your_host_name",
"port": Debugging_port
}
]
Example :
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Attach)",
"projectName": "MyApplication",
"request": "attach",
"hostName": "localhost",
"port": 8787
}
]
I am using wildfly server. So the default debugging port is 8787.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With