This package provides additional Java programming language support for eglot.
- Few convenience functions are available for common operations such as creating a new project or class.
- The Eclipse JDT Language Server is automatically installed (if needed) when you open a Java file: this gives you code completion, refactoring capabilities, etc.
Function | Description |
---|---|
eglot-java-project-new | Create new projects with a wizard (spring, Maven or Gradle projects) |
eglot-java-project-build-refresh | Rebuild the current project |
eglot-java-project-build-task | Run a build task using Gradle or Maven for the current project |
eglot-java-file-new | Wizard for creating new Java files |
eglot-java-run-main | Run the current main class |
eglot-java-run-test | Run the current test (JUnit only, unless you run Maven or Gradle tasks) |
- The only direct Emacs package dependency is eglot, assuming you’re running a recent Emacs version.
- The Eclipse JDT Language server along with the JUnit console runner are configured to be automatically installed when not found at default locations (see
M-x customize-group
eglot-java).- The Eclipse JDT.LS team mentions that there’s support for compiling projects from Java 1.5 through 16, but you’re encouraged to use recent versions of the Java Development Toolkit (JDK).
- This extension has been tested with recent Java and Eclipse JDT snapshot versions for few years (since roughly mid-2018).
- Please also configure your PATH environment variable for Maven and/or for Gradle.
Copy the contents of eglot-java.el to a new Emacs buffer and run the command M-x package-install-from-buffer
.
You can configure few settings to reflect your preferences via M-x customize-group
(eglot-java): LSP server installation folder, etc.
- The default
java-mode
keybindings are controlled by the custom variableeglot-java-default-bindings-enabled
. - The default prefix key for available functions is defined by the variable
eglot-java-prefix-key
(C-c l
).
Please find below a simple initialization of this package.
(eval-after-load 'eglot-java
(progn
(require 'eglot-java)
'(eglot-java-init)))