[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: java anyone?
From: |
Pankaj Jangid |
Subject: |
Re: java anyone? |
Date: |
Sun, 18 Jul 2021 16:56:45 +0530 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) |
Jean-Christophe Helary <lists@traduction-libre.org> writes:
> I need something where I can just lookup functions in a code base with
> a local javadoc tree, including online Oracle documentation, etc. Not
> a full-fledged IDE with completion.
I use a very lightweight language server facilitator, named Eglot. There
are a couple of settings that are required for this to work. This is the
minimal set that I came-up with after discussing in and following the
Eglot tracker.
1. Tell Emacs the value of JAVA_HOME. ‘(setenv "JAVA_HOME" ...)’
2. By default, Eglot uses, Eclipse JDT Language server so you need to
install it somewhere. I simply pulled the git repository at
~/.emacs.d/eclipse.jdt.ls. After building the Eclipse JDT LS (‘mvn
clean; mvn package’), you must add the language server JAR to the
CLASSPATH. I use the following snippet:
--8<---------------cut here---------------start------------->8---
(defun 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 ":"))))
(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---
Eglot works with project.el, xref.el, eldoc.el etc. So many usual things
will work out of the box. Like online help when the point is inside a
function name.
It also works with company; but that is not required.