lsp-java
lsp-java copied to clipboard
avoid recompile and reimport
Is it possible to avoid jdtls recompiling the classes? I am now working on a project which only supports java 8. I noticed that when I start the lsp it gonna import dependencies and compile the class files but I don't want it to do so.
Compiling with java 11 would throw the belowing exception and I could not modify the source codes.
Exception in thread "main" java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
Thus I am wondering whether lsp could just use the precompiled class files?
Thanks.
I think that in this case you have to configure jdtls to use different jdk per project - see https://github.com/emacs-lsp/lsp-java/issues/254
@yyoncho
I think that in this case you have to configure jdtls to use different jdk per project - see #254
I try to add this to my config
(setq lsp-java-configuration-runtimes '[
(:name "JavaSE-11"
:path "/usr/lib/jvm/java-11-openjdk/")
(:name "JavaSE-1.8"
:path "/usr/lib/jvm/java-8-openjdk/"
:default t)
]))
However, I saw the jdtls was still compiling the project. I am not sure if it compiled the classes correctly(I compile the project in docker with some legacy dependencies which are not in my local working env). I could only know this doesn't work until I meet the identical exception.
Thanks anyways. Maybe I could have a look to the jdtls project and check whether there is such a configurable property.
It is not possible to disable jdtls compiling the files, this is how it works...
@ST-Saint I am not sure if (setq lsp-java-autobuild-enabled nil)
is what you want.