Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork247
Java
The debug adapter for Java is an extension toeclipse.jdt.ls:java-debug.
That means in order to use the debug adapter you need a language-server-protocol client.There is no standalone Java debug adapter
Installnvim-jdtls and follow the instructions in the README to setup nvim-dap.
Youdo not have to definedap.adapters.java yourself.
You'll need a LSP client that supports executing custom commands. You'll have to installjava-debug and configure eclipse.jdt.ls to load it, seeUsage with eclipse.jdt.ls
Then you can define something like this:
localdap=require('dap')dap.adapters.java=function(callback)-- FIXME:-- Here a function needs to trigger the `vscode.java.startDebugSession` LSP command-- The response to the command must be the `port` used belowcallback({type='server';host='127.0.0.1';port=port; })end
You may also want to add a configuration to debug remote applications:
localdap=require('dap')dap.configurations.java= { {type='java';request='attach';name="Debug (Attach) - Remote";hostName="127.0.0.1";port=5005; },}
A configuration to launch a main class could look like this:
localdap=require('dap')dap.configurations.java= { {-- You need to extend the classPath to list your dependencies.-- `nvim-jdtls` would automatically add the `classPaths` property if it is missingclassPaths= {},-- If using multi-module projects, remove otherwise.projectName="yourProjectName",javaExec="/path/to/your/bin/java",mainClass="your.package.name.MainClassName",-- If using the JDK9+ module system, this needs to be extended-- `nvim-jdtls` would automatically populate this propertymodulePaths= {},name="Launch YourClassName",request="launch",type="java" },}
To get an overview of all availableattach andlaunch options, take a look atjava-debug options. Keep in mind that anyjava.debug options are settings of the vscode-java client extension and not understood by the debug-adapter itself.