Enterprise Java Development in Emacs | skybert.net

Enterprise Java Development in Emacs


png

Support for Lombok

(setq lsp-java-vmargs
      (list
         "-noverify"
         "-Xmx1G"
         "-XX:+UseG1GC"
         "-XX:+UseStringDeduplication"
         "-javaagent:/path/to/lombok-1.16.18.jar"
         "-Xbootclasspath/a:/path/to/lombok-1.16.18.jar"))

Trouble shooting

If lsp-java doesn't work, a good place to start is to look in the Eclipse server log file:

$ tail -f ~/.emacs.d/workspace/.metadata/.log

java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer;

You need to make the language server use Java 9 and it must be OpenJDK:

(setq lsp-java-java-path
      "/usr/lib/jvm/java-9-openjdk-amd64/bin/java")

See this ticket over at jira.mongodb.org for a good explanation of why these errors happen

java.security.InvalidAlgorithmParameterException

java.security.InvalidAlgorithmParameterException: the
trustAnchors parameter must be non-empty

The easiest solution is to just use OpenJDK instead of Oracle Java to run the Eclipse server (I just did apt-get install openjdk-9-jdk), you can set this in your .emacs by setting lsp-java-java-path, see above.

NoClassDefFoundError: javax/annotation/processing/AbstractProcessor

!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.resources".
!STACK 0
java.lang.NoClassDefFoundError: javax/annotation/processing/AbstractProcessor
    at java.base/java.lang.ClassLoader.findBootstrapClass(Native Method)
    at java.base/java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:1248)
    at java.base/java.lang.System$2.findBootstrapClassOrNull(System.java:2123)

Other Java extensions for Emacs I've used


Licensed under CC BY Creative Commons License ~ gmail torstein.k.johansen @ gmail ~ twitter @torsteinkrause ~