0

I tried to follow the tutorial on this link and when I arrived to the Working with Java Project section, I found I cannot initialize a project. Everything shows up as expected until It asks for a project directory. After this, nothing happens even when JAVA_HOME and lsp-java-java-path are set manually.

Versions:

  • emacs: 27.1
  • lsp-java: 3.1
  • dap-mode: 0.8
  • lsp-mode: 9.0.0
  • lsp-treemacs: 0.5
  • treemacs: 3.1

~/.emacs file:

   (custom-set-variables
 ;; 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.
 '(ansi-color-faces-vector
   [default default default italic underline success warning error])
 '(ansi-color-names-vector
   ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
 '(column-number-mode t)
 '(custom-enabled-themes '(wombat))
 '(display-battery-mode t)
 '(display-line-numbers 'relative)
 '(display-line-numbers-type 'relative)
 '(display-time-24hr-format t)
 '(display-time-day-and-date t)
 '(display-time-mode t)
 '(flycheck-global-modes t)
 '(font-use-system-font nil)
 '(global-flycheck-mode t)
 '(global-highlight-changes-mode nil)
 '(global-hl-line-mode t)
 '(highlight-changes-colors
   '("yellow" "magenta" "blue" "maroon" "firebrick" "green4" "DarkOrchid"))
 '(highlight-changes-face-list nil)
 '(highlight-changes-global-changes-existing-buffers t)
 '(hl-line-sticky-flag nil)
 '(inhibit-startup-screen t)
 '(ispell-dictionary nil)
 '(menu-bar-mode nil)
 '(nerd-icons-font-family "Symbols Nerd Font Mono")
 '(package-selected-packages
   '(lsp-ui lsp-java nerd-icons-ivy-rich nerd-icons-ibuffer nerd-icons-corfu nerd-icons flymake-eslint vue-mode vue-html-mode projectile pylint gnu-elpa-keyring-update flycheck-pycheckers flycheck elpy magit))
 '(projectile-mode t nil (projectile))
 '(tab-bar-mode t)
 '(tool-bar-mode nil)
 '(tool-bar-position 'bottom)
 '(treemacs-collapse-dirs 3)
 '(treemacs-git-mode t)
 '(user-mail-address "[email protected]")
 '(vue-html-color-interpolations t))
(custom-set-faces
 ;; 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.
 '(default ((t (:family "GoMono Nerd Font" :foundry "    " :slant normal :weight normal :height 128 :width normal))))
 '(header-line-highlight ((t (:inherit highlight))))
 '(highlight ((t (:background "dark slate blue" :foreground "white" :underline t))))
 '(hl-line ((t (:inherit nil :extend t :background "#3e4446"))))
 '(line-number-current-line ((t (:inherit nil :background "gray26" :foreground "cornflower blue"))))
 '(region ((t (:extend t :background "dark slate blue" :foreground "white"))))
 '(tab-bar ((t (:inherit variable-pitch :background "dim gray" :foreground "NavajoWhite1"))))
 '(tab-bar-tab ((t (:inherit tab-bar :background "royal blue" :box (:line-width 1 :style released-button)))))
 '(tab-bar-tab-inactive ((t (:inherit tab-bar-tab :background "dim gray"))))
 '(tab-line-tab-current ((t (:inherit tab-line-tab))))
 '(variable-pitch ((t (:family "GoMono Nerd Font")))))

;; Added by me
(require 'package)
(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/") t)

(elpy-enable)

(add-to-list 'display-buffer-alist
             `(,(rx bos "*Flycheck errors*" eos)
              (display-buffer-reuse-window
               display-buffer-in-side-window)
              (side            . bottom)
              (reusable-frames . visible)
              (window-height   . 0.20)))

;;(add-hook 'emacs-startup-hook 'treemacs)
(define-key flymake-mode-map (kbd "M-n") 'flymake-goto-next-error)
(define-key flymake-mode-map (kbd "M-p") 'flymake-goto-prev-error)
(global-set-key (kbd "<M-dead-circumflex>") 'join-line)
(global-set-key (kbd "<C-dead-circumflex>") 'next-line)

(put 'upcase-region 'disabled nil)
(defun on-after-init ()
  (unless (display-graphic-p (selected-frame))
    (set-face-background 'default "unspecified-bg" (selected-frame))))

(add-hook 'window-setup-hook 'on-after-init)

(setenv "JAVA_HOME" "/usr/lib/jvm/openjdk-21/")
(setq lsp-java-java-path "/usr/bin/java")

(require 'lsp-java)
(add-hook 'java-mode-hook #'lsp)

(require 'lsp-java-boot)

;; to enable the lenses
(add-hook 'lsp-mode-hook #'lsp-lens-mode)
(add-hook 'java-mode-hook #'lsp-java-boot-lens-mode)

0

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.