unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Pankaj Jangid <pankaj@codeisgreat.org>
To: Alessandro Bertulli <alessandro.bertulli96@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Editing Java (with LSP)
Date: Thu, 16 Jun 2022 08:59:19 +0530	[thread overview]
Message-ID: <87pmj99tgw.fsf@codeisgreat.org> (raw)
In-Reply-To: <87k09ky8kc.fsf@gmail.com> (Alessandro Bertulli's message of "Mon, 13 Jun 2022 15:43:46 +0200")

Alessandro Bertulli
<alessandro.bertulli96@gmail.com> writes:

> Can you please give me your feedback? Does any of you write Java code?
> How is it? Do you have the same problems too? If yes, have you found a
> solution? Do you use LSP? Or some other package?
>

I use eglot+eclipse.jdt.ls. There is a bit of struggle in setting this
up.

Although, eglot tries to download latest eclipse.jdt.ls but it is not
always perfect. There are CLASSPATH issues and all those things which
are typical of Java. And even after full setup I face issues here and
there. Sometimes.

My setup is like this (assuming you have cloned eclipse.jdt.ls
repository inside ~/.emacs.d and built using ‘./mvnw clean package’),

--8<---------------cut here---------------start------------->8---
(unless (package-installed-p 'eglot)
  (package-install 'eglot))
(custom-set-variables
 '(eglot-connect-timeout nil))
(declare-function eglot-ensure "eglot")
(add-hook 'java-mode-hook
		  #'eglot-ensure)				; eclipse.jdt.ls


(defun my/add-to-classpath (item)
  "Add ITEM to CLASSPATH."
  
  (let ((class-path (getenv "CLASSPATH")))
    
    (defvar class-path-list (if class-path
				(split-string class-path ":")))
    (cl-pushnew item class-path-list)
    (setenv "CLASSPATH"
	    (mapconcat 'identity class-path-list ":"))))

(when (file-exists-p (expand-file-name "eclipse.jdt.ls" user-emacs-directory))
  (my/add-to-classpath
   (substring
    (shell-command-to-string
     (format
      "find %s -name 'org.eclipse.equinox.launcher_*jar'"
      (expand-file-name
       "eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins"
       user-emacs-directory)))
    0 -1)))
--8<---------------cut here---------------end--------------->8---

Also I use ‘exec-path-from-shell’ package to setup PATHs in GUI Emacs.

~Pankaj



  parent reply	other threads:[~2022-06-16  3:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-13 13:43 Editing Java (with LSP) Alessandro Bertulli
2022-06-13 15:48 ` Filipp Gunbin
2022-06-13 21:53   ` Alessandro Bertulli
2022-06-14 19:12     ` Filipp Gunbin
2022-06-13 20:32 ` Milan Zamazal
2022-06-16  3:29 ` Pankaj Jangid [this message]
2022-06-16 13:34   ` Alessandro Bertulli
2022-06-17  3:27     ` Pankaj Jangid
  -- strict thread matches above, loose matches on Subject: below --
2022-06-13 21:35 Alessandro Bertulli
2022-06-14 19:13 ` Milan Zamazal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pmj99tgw.fsf@codeisgreat.org \
    --to=pankaj@codeisgreat.org \
    --cc=alessandro.bertulli96@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).