40

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?

6
  • 1
    I'm still wondering in 2018 Commented Mar 23, 2018 at 20:48
  • 3
    Still relevant in 2021 @GabrielBB :D Commented May 28, 2021 at 13:34
  • 1
    Still relevant in 2022 Commented Sep 7, 2022 at 2:00
  • 1
    Still relevant in 2023. Commented Aug 1, 2023 at 15:29
  • 3
    Still relevant in 2024 Commented Mar 15, 2024 at 20:14

1 Answer 1

63

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.

Sign up to request clarification or add additional context in comments.

4 Comments

When using Wildfly, you have to start the server with debug option: stanadalone.bat --debug 8787
Thanks! I use gradle task with JavaExec so adding debugOptions section did the work for me in order to connect
How to do the same, that is, remote debug Java web application running on Tomcat from vs code?
How can you pass arguments for the remote JVM? (e.g. -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.