31

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?

Jackie
  • 21,969
  • 32
  • 147
  • 289

1 Answers1

50

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.

Aman Verma
  • 549
  • 7
  • 11
  • 1
    When using Wildfly, you have to start the server with debug option: stanadalone.bat --debug 8787 – user2571962 Apr 29 '19 at 11:56
  • Thanks! I use gradle task with [JavaExec](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.JavaExec.html) so adding `debugOptions` section did the work for me in order to connect – jurl May 25 '21 at 08:39
  • How to do the same, that is, remote debug Java web application running on Tomcat from vs code? – tarekahf Sep 18 '21 at 05:24