I'm trying to run a simple HelloWorld from Emacs using dap-mode commands dap-debug and dap-java-debug but prompted the error saying

lsp-request: No delegateCommandHandler for vscode.java.resolveMainClass

So I try to update the language server to see if it helps (see this issue) by running

M-x lsp-java-update-server

Then I'm stuck in the process of downloading the jdt-language-server-latest.tar.gz package and eventually the updating fails due to downloading timeout. So I manually download the package from the address as shown in the updating log and put it under my lsp-java-server-install-dir which is ~/.emacs.d/eclipse.jdt.ls/server/ and then run lsp-java-update-server again. Still it attempts to download the package and is stuck there. Is it possible to skip the downloading step and continue to the following steps? Also I have installed lsp-java successfully in the same way and features like real-time diagnostics (via flymake) and code completion (via company-lsp) all work fine. So I suppose the language server should be the latest version but something is still missing such as some dependencies it would require since I installed it manually. I also tried to find a clue from the source code of lsp-java-update-server but I'm new to elisp so didn't really find anything helpful.

My init file:

;; Bad request problem 
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")

;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.

 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ace-window-display-mode nil)
   [default default default italic underline success warning error])
 '(aw-background nil)
 '(blink-matching-paren t)
 '(browse-url-browser-function (quote browse-url-chrome))
 '(column-number-mode t nil nil "Show column number")
 '(company-show-numbers t)
    ("a24c5b3c12d147da6cef80938dca1223b7c7f70f2f382b26308eba014dc4833a" "624f3b1e86a81d1873b93edc3cce0947f2042bfeebecc480b393ff1e0aa4abfd" default)))
 '(electric-pair-mode t)
 '(hl-sexp-background-color "#1c1f26")
 '(inhibit-startup-screen t nil nil "Hide welcome screen")
 '(lsp-java-format-settings-profile "GoogleStyle")
 '(lsp-java-format-settings-url "~/Downloads/eclipse-java-google-style.xml")
 '(minibuffer-eldef-shorten-default t)
 '(minibuffer-electric-default-mode t)
 '(mode-require-final-newline nil)
 '(org-replace-disputed-keys t)
 '(package-check-signature (quote allow-unsigned))
    (dap-mode lsp-ui company-lsp use-package yasnippet lsp-java gnu-elpa-keyring-update nov magit projectile)))
 '(set-mark-command-repeat-pop t)
 '(show-paren-mode t)
 '(tab-width 4)
 '(tool-bar-mode nil)
 '(tool-bar-position (quote top))
 '(tooltip-mode nil))

 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.

(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)

;; === Custom keybindings
(global-set-key (kbd "<S-return>") 'newline-below-without-break)
(global-set-key (kbd "<C-S-return>") 'newline-above-without-break)
(global-set-key (kbd "M-]") 'xah-forward-block)
(global-set-key (kbd "M-[") 'xah-backward-block)
(global-set-key (kbd "<C-tab>") 'other-window)
(global-set-key (kbd "<C-iso-lefttab>") 'prev-window)
(global-set-key (kbd "<M-S-backspace>") 'previous-buffer)
(global-set-key (kbd "<C-M-backspace>") 'next-buffer)
(global-set-key (kbd "<M-f2>") 'browse-url-of-file)
(global-set-key (kbd "M-o") 'ace-window)
(global-set-key (kbd "<C-f5>") 'lsp-format-buffer)
(global-set-key (kbd "<C-S-f5>") 'lsp-format-region)
(global-set-key [(meta shift ?s)] 'lsp-find-references)
;; (global-set-key [?\M-\S-s] 'lsp-find-references)
;; (global-set-key (kbd "M-S-s") 'lsp-find-references)
;; (global-set-key (kbd "<M-shift-s>") 'lsp-find-references)
(global-set-key (kbd "C->") 'lsp-goto-implementation)
(global-set-key (kbd "C-<") 'lsp-java-open-super-implementation)
(global-set-key (kbd "M-h") 'lsp-ui-find-next-reference)
(global-set-key (kbd "M-H") 'lsp-ui-find-prev-reference)

;; Open new line below current line without breaking current line
(defun newline-below-without-break ()
  "1.Move to end of line; 2. Insert newline with index"
  (let ((oldpos (point))) (end-of-line) (newline-and-indent)))

;; Open new line above current line without breaking current line
(defun newline-above-without-break ()
  "Insert an empty line above the currentline. Position the cursor at its beginning, according the current mode"
  (move-beginning-of-line nil)
  (forward-line -1)

;; Move to next blank line separated block
(defun xah-forward-block (&optional n)
  "Move cursor beginning of next text block.
A text block is separated by blank lines.
This command similar to `forward-paragraph', but this command's behavior is the same regardless of syntax table.
URL `http://ergoemacs.org/emacs/emacs_move_by_paragraph.html'
Version 2016-06-15"
  (interactive "p")
  (let ((n (if (null n) 1 n)))
    (re-search-forward "\n[\t\n ]*\n+" nil "NOERROR" n)))

;; Move to previous blank line separated block
(defun xah-backward-block (&optional n)
  "Move cursor to previous text block.
See: `xah-forward-block'
URL `http://ergoemacs.org/emacs/emacs_move_by_paragraph.html'
Version 2016-06-15"
  (interactive "p")
  (let ((n (if (null n) 1 n))
        ($i 1))
    (while (<= $i n)
      (if (re-search-backward "\n[\t\n ]*\n+" nil "NOERROR")
          (progn (skip-chars-backward "\n\t "))
        (progn (goto-char (point-min))
               (setq $i n)))
      (setq $i (1+ $i)))))

(defun prev-window () (interactive) (other-window -1))

;; === Theme
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
(load-theme 'zenburn t t)
(enable-theme 'zenburn)

;; === Packages
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
                    (not (gnutls-available-p))))
       (proto (if no-ssl "http" "https")))
  (when no-ssl
    (warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the-middle attacks.
There are two things you can do about this warning:
1. Install an Emacs version that does support SSL and be safe.
2. Remove this warning from your init file so you won't see it again."))
  ;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
  (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
  ;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
  (when (< emacs-major-version 24)
    ;; For important compatibility libraries like cl-lib
    (add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))

(require 'projectile)
(define-key projectile-mode-map (kbd "M-p") 'projectile-command-map)
(projectile-mode +1)

;; === VCS
(global-set-key (kbd "C-x g") 'magit-status)
(global-set-key (kbd "C-c g") 'magit-file-dispatch)

(require 'lsp-java)
(add-hook 'java-mode-hook #'lsp)
(add-hook 'after-init-hook 'global-company-mode)

(require 'cc-mode)

(condition-case nil
    (require 'use-package)
   (require 'package)
   (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
   (package-install 'use-package)
   (require 'use-package)))

(use-package projectile :ensure t)
(use-package yasnippet :ensure t)
(use-package lsp-mode :ensure t)
(use-package hydra :ensure t)
(use-package company-lsp :ensure t)
(use-package lsp-ui :ensure t)
(use-package lsp-java :ensure t :after lsp
  :config (add-hook 'java-mode-hook 'lsp))

(use-package dap-mode
  :ensure t :after lsp-mode
  (dap-mode t)
  (dap-ui-mode t))

(use-package dap-java :after (lsp-java))

(with-eval-after-load 'org       
  (setq org-startup-indented t) ; Enable `org-indent-mode' by default
  (add-hook 'org-mode-hook #'visual-line-mode))

(setq find-function-C-source-directory "~/Projects/emacs-26.2/src/")

1 Answer 1


ATM there are no manual instructions, please open an issue in lsp-java repo. To fix your problem do:

  1. M-x lsp-java-update-server - do that to force lsp-java to download the install pom.xml and cancel the task.

  2. In the *Messages* buffer there will be something like this:

Wrote /tmp/lsp-java-install4rWMay/pom.xml
/usr/bin/mvn -Djdt.js.server.root=/home/kyoncho/.emacs.d/eclipse.jdt.ls/server/ -Djunit.runner.root=/home/kyoncho/.emacs.d/eclipse.jdt.ls/test-runner/ -Djunit.runner.fileName=junit-platform-console-standalone.jar -Djava.debug.root=/home/kyoncho/.emacs.d/eclipse.jdt.ls/server/bundles clean package -Djdt.download.url=https://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz: exited abnormally with code 130.
  1. Go into /tmp/lsp-java-install4rWMay/ directory and edit pom.xml to remove the download language server task:


                <untar src="${project.build.directory}/jdt-language-server-latest.tar.gz" compression="gzip" dest="${jdt.js.server.root}" />
  1. Rerun the failing command in the temp directory:
/usr/bin/mvn -Djdt.js.server.root=/home/kyoncho/.emacs.d/eclipse.jdt.ls/server/ -Djunit.runner.root=/home/kyoncho/.emacs.d/eclipse.jdt.ls/test-runner/ -Djunit.runner.fileName=junit-platform-console-standalone.jar -Djava.debug.root=/home/kyoncho/.emacs.d/eclipse.jdt.ls/server/bundles clean package -Djdt.download.url=https://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.