doomemacs/modules/lang/java
Henrik Lissner 037b018cdd
feat: add .doommodule files
These optional dotfiles indicate the root of a module or module
group (:lang), and will later contain module metadata. They will also
serve as an alternative to packages.el and doctor.el, and will aide the
parts of the v3.0 module API concerned with resolving the current module
from a path (`doom-module-from-path`), which currently rely too heavily
on parsing path strings.

For now, however, they're simply placeholders.
2024-09-14 20:47:39 -04:00
..
autoload feat(java): java.el takes java-ts-mode into account 2024-03-10 00:54:34 -05:00
+eclim.el refactor: deprecate featurep! for modulep! 2022-08-14 20:43:35 +02:00
+lsp.el refactor(lsp): let lsp-mode load lsp client packages 2024-09-09 17:24:45 -04:00
+meghanada.el tweak(syntax): feat gate flycheck in all modules 2023-07-25 00:11:09 +01:00
.doommodule feat: add .doommodule files 2024-09-14 20:47:39 -04:00
config.el refactor: use true eos regex in auto-mode-alist entries 2024-08-25 17:44:29 -04:00
doctor.el refactor: deprecate featurep! for modulep! 2022-08-14 20:43:35 +02:00
packages.el bump: :lang 2024-09-07 19:04:37 -04:00
README.org docs(*): replace all-the-icons with nerd-icons 2023-09-16 20:19:11 +02:00

:lang java

Description   unfold

This module adds Java support to Doom Emacs, including android-mode and groovy-mode.

Maintainers

This module has no dedicated maintainers. Become a maintainer?

Module flags

+lsp
Enable LSP support for java-mode. Requires doom-module::tools lsp and a langserver (supports eclipse.jdt.ls). Incompatible with doom-module:+meghanada.
+meghanada
Enable doom-package:meghanada-mode. Incompatible with doom-module:+lsp.
+tree-sitter
Leverages tree-sitter for better syntax highlighting and structural text editing. Requires doom-module::tools tree-sitter.

Hacks

No hacks documented for this module.

TODO Changelog

This module does not have a changelog yet.

Installation

Enable this module in your doom! block.

This module requires:

OpenJDK 11

Ubuntu

#+begin-src sh apt-get install openjdk-11-jdk-headless

#+end_src

Fedora

dnf install java-11-openjdk

Oracle JDK 11

Ubuntu

add-apt-repository ppa:linuxuprising/java
apt update
apt install oracle-java11-installer
apt install oracle-java11-set-default

Fedora

curl -O https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz
tar zxvf openjdk-11.0.2_linux-x64_bin.tar.gz
sudo mv jdk-11.0.2/ /usr/local/

Open /etc/profile.d/jdk11.sh as root and add:

export JAVA_HOME=/usr/local/jdk-11.0.2
export PATH=$PATH:$JAVA_HOME/bin

Save the file and source it:

source /etc/profile.d/jdk11.sh
java -version

Multiple Java Versions

It is common to need support for multiple Java versions. You can use a generic tool like jabba to install and manage multiple Java versions on any OS.

To have a different version of Java per-project, it is recommended you use direnv and doom-module::tools direnv; create a .envrc in the root of the project pointing to the Java installation:

PATH_add ~/.jabba/jdk/adopt@1.11.0-3
JAVA_HOME=~/.jabba/jdk/adopt@1.11.0-3

And then run $ direnv allow . in the project directory. The doom-module::tools direnv module will automatically source this environment before activating LSP servers.

Formatter

doom-module::editor format uses google-java-format to handle formatting.

To install, grab the latest all-deps.jar release from the above, put it somewhere and create a script similar to the below:

/usr/local/bin/google-java-format

java -jar /path/to/google-java-format-all-deps.jar

TODO Usage

󱌣 This module's usage documentation is incomplete. Complete it?

doom-module:+lsp features

According to https://github.com/emacs-lsp/lsp-java, you get:

+meghanada features

According to https://github.com/mopemope/meghanada-emacs/, you get:

TODO Configuration

󱌣 This module's configuration documentation is incomplete. Complete it?

doom-module:+lsp

Install the eclipse server by executing M-x lsp-install-server and selecting jdtls. After that any newly opened java files should start the LSP server automatically.

To update the server, perform SPC u M-x lsp-install-server.

Note that if you change Java version you may need to remove the LSP server and install it again. You can do this with M-x +lsp/uninstall-server followed by M-x lsp-install-server.

Enable the doom-module::tools debugger +lsp module to get test runner support.

Troubleshooting

There are no known problems with this module. Report one?

Frequently asked questions

This module has no FAQs yet. Ask one?

TODO Appendix

󱌣 This module has no appendix yet. Write one?