Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Trying to get Java Debugging working with Vim. Any help.

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
User avatar
kau-92
Posts: 46
Joined: 2020-12-16 12:49

Trying to get Java Debugging working with Vim. Any help.

#1 Post by kau-92 »

Hey there, :)

am trying to get Java debugging to work with Vim. I really want to get practice using a debugger as I upto now have used only print statement debugging.
I'm also thinking of moving to neovim.

I've installed vim-lsp https://github.com/prabirshrestha/vim-lsp
I've installed vimspector - A multi language graphical debugger for Vim
I've installed Java Debug Server for Visual Studio Code https://github.com/microsoft/java-debug
I've installed Eclipse JDT Language Server https://github.com/eclipse/eclipse.jdt.ls

This is all following the blog post : https://urfoex.blogspot.com/2020/08/deb ... r-vim.html
Section Connecting with Vim:

All my effort was trying to get

Code: Select all

:call lsp#send_request('eclipse-jdt-ls', {'method': 'workspace/executeCommand', 'params': {'command': 'vscode.java.startDebugSession'}, 'on_notification': function('lsp#utils#error')})
to work. I think its supposed to give me a port number to put as DAPPort number when its prompted when debugger is run.
This command did not work to full extent. I get the following error:
Error detected while processing function lsp#send_request[6]..
E716: Key not present in Dictionary: "eclipse-jdt-ls"


Anyway I got Eclipse JDT Language Server working I think.

when I run

Code: Select all

java \
	-Declipse.application=org.eclipse.jdt.ls.core.id1 \
	-Dosgi.bundles.defaultStartLevel=4 \
	-Declipse.product=org.eclipse.jdt.ls.core.product \
	-Dlog.level=ALL \
	-noverify \
	-Xmx1G \
	-jar ./plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar \
	-configuration ./config_linux \
	-data /home/etc etc/Data/ \
	--add-modules=ALL-SYSTEM \
	--add-opens java.base/java.util=ALL-UNNAMED \
	--add-opens java.base/java.lang=ALL-UNNAMED
I get:

Code: Select all

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"28 Nov 2021, 17:30:31 Main thread is waiting"}}
So Im guessing the server is up and running.

So I have edited .bashrc and added the environment variables I seem to need to add.

Code: Select all

#made for getting Ecliple.jdt.ls java language server to work, for debugging
#where jdt.ls client reads from
export STDIN_PIPE_NAME="JDTC_READ"
#where jdt.ls client writes to
export STDOUT_PIPE_NAME="JDTC_WRITE"
#
#port client reads
export STDIN_PORT="2005"
#port client writes to
export STDOUT_PORT="2006"
So the configuration file :

Code: Select all

{
  "configurations": {
    "Java Attach": {
      "adapter": "vscode-java",
      "configuration": {
        "request": "attach",
        "hostName": "${host}",
        "port": "${2005}",
        "projectName": "${Board}",
        "sourcePaths": [
          "${workspaceRoot}/src/main/java",
          "${workspaceRoot}/src/test/java"
        ]
      }
    }
  }
}
I'm putting port 2006 as DAPport when starting the vimspector with F5. But I'm unsure if port 2005 and 2006 are the numbers to use. and I'm not sure if I should be using "adapter": "vscode-java", (like that should be 'java-language-server'). I've tried 'VimspectorInstall java-language-server' but it brought no success either.
I try to enter the debugger screen by pressing F5. I put localhost as host, and 2005 as port, 2006 as DAPport, Board (main class name) as projectname, but I get 'Unable to start or connect to debug adapter'. Last log line gives : '81 2021-11-28 21:21:22,283 - INFO - Failed to launch or attach to the debug adapter'

I'm somewhat confused and not sure how to put these things together. Or if I even need something else. This day has been a lot of work above and I am not really close to getting the damn Java debugging working. It would be a nightmare to go through this kind of thing for every language I want to work with. Anyway if any of you are familiar with this can you point out a fault or a solution?

User avatar
kau-92
Posts: 46
Joined: 2020-12-16 12:49

Re: Trying to get Java Debugging working with Vim. Any help.

#2 Post by kau-92 »

I've now tried to install 'YouCompleteMe' but it was not successful.
I've now tried to install coc-java and coc-java-vimspector, and that seems successful but but that also gave an error when trying to run debugger.

I think I'm going to stop here.

arzgi
Posts: 1183
Joined: 2008-02-21 17:03
Location: Finland
Been thanked: 31 times

Re: Trying to get Java Debugging working with Vim. Any help.

#3 Post by arzgi »

I don't use java, but have used vim for years.

you-complete-me works nice for me (for languages I use), but it is not a debugger.

First I did

Code: Select all

:~$ aptitude search java | grep debug
p  libeclipse-debug-core-java - Eclipse Debug Core
p  libeclipse-debug-ui-java - Eclipse Debug UI
p  libeclipse-jdt-debug-java - Eclipse JDI Debug Model
p  libeclipse-jdt-debug-ui-java - Eclipse JDI Debug UI
p  libmatthew-debug-java - Debugging library for Java
:~$ 
I would check that last in the list. The second option I'd use if could not find any good in the Debian's repo, go to vim.org select scripts, you can search there.

Post Reply