Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do attach to a remote Java debugger using Visual Studio Code

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?

like image 292
Jackie Avatar asked Jun 05 '17 15:06

Jackie


People also ask

How do I connect to Visual Studio Remote debugger?

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.

How do I add Java debugger to Visual Studio Code?

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.

How do I connect to a remote server using Visual Studio Code?

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.


1 Answers

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.

like image 175
Aman Verma Avatar answered Sep 21 '22 17:09

Aman Verma