java language server

有没有人成功让eclipse.jdt.ls在emacs上工作的?

由于我自己编译,在某一步遇到了handshake_failure的错误,于是就从这里下载了编译好的版本。

以下错误不管是snapshots还是milestone都遇到了:

我把tar.gzAUR的方法(我在ubuntu上安装的)解压到$HOME/.local/share/java/jdtls下,并把AUR中的launcher.sh保存成了$HOME/.local/bin/jdtls(当然修改了对应路径)。

对于eglot,我直接设置成(java-mode . ("~/.local/bin/jdtls"))

打开一个.java之后,eglot会显示它链接server成功,不过,eglotmode-line很快就会显示error,并且当我尝试用xref-find-defination一个局部变量的定义时,jsonrpc会返回一个空指针的异常。。。

试试lsp-java吧,开箱即用

lsp-java + dap-java ,打开就能用啊

我试了一下meghanada,报的错是com.sun.tools.javac.tree某个类找不到。估计jdtls也是类似的原因。

我用jdeps扫了一下缺什么包,meghanada没被扫出来,然而jdtls缺的包巨多,有什么方法根据jdeps的结果安装包吗?

用lsp-java吧,脏活都帮你搞定了。

看了下是用maven安装的

我现在使用了lsp-java,当我打开一个有.project的项目下的文件时,为什么lsp-java还说此文件不属于某个项目?这个不是自动检测的吗?

原来是叫你选。。。

出了和我用AUR+eglot一样的错误:

java.lang.NullPointerException                                                                                                                                                                                     
        at org.eclipse.jdt.internal.compiler.util.JRTUtil.walkModuleImage(JRTUtil.java:158)                                                                                                                        
        at org.eclipse.jdt.internal.core.JavaProject.loadModulesInJimage(JavaProject.java:926)                                                                                                                     
        at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:726)                                                                                                             
        at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:1046)                                                                                                            
        at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:991)                                                                                                             
        at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:968)                                                                                                             
        at org.eclipse.jdt.internal.core.JavaProject.buildStructure(JavaProject.java:482)                                                                                                                          
        at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:268)                                                                                                                                 
        at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:596)                                                                                                                          
        at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:326)                                                                                                                          
        at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:312)                                                                                                                          
        at org.eclipse.jdt.internal.core.JavaElement.getChildren(JavaElement.java:267)                                                                                                                             
        at org.eclipse.jdt.internal.core.JavaProject.getPackageFragmentRoots(JavaProject.java:2274)                                                                                                                
        at org.eclipse.jdt.internal.core.JavaProject.getPackageFragments(JavaProject.java:2298)                                                                                                                    
        at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.cleanupResources(ProjectsManager.java:217)                                                                                                    
        at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.initializeProjects(ProjectsManager.java:137)                                                                                                  
        at org.eclipse.jdt.ls.core.internal.handlers.InitHandler$1.runInWorkspace(InitHandler.java:246)                                                                                                            
        at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:42)                                                                                                              
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

java.lang.NullPointerException                                                                                                                                                                                     
        at org.eclipse.jdt.internal.compiler.util.JRTUtil.walkModuleImage(JRTUtil.java:158)                                                                                                                        
        at org.eclipse.jdt.internal.core.JavaProject.loadModulesInJimage(JavaProject.java:926)                                                                                                                     
        at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:726)                                                                                                             
        at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:1046)                                                                                                            
        at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:991)                                                                                                             
        at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:968)                                                                                                             
        at org.eclipse.jdt.internal.core.JavaProject.buildStructure(JavaProject.java:482)                                                                                                                          
        at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:268)                                                                                                                                 
        at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:596)                                                                                                                          
        at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:326)                                                                                                                          
        at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:312)                                                                                                                          
        at org.eclipse.jdt.internal.core.JavaProject.getModuleDescription(JavaProject.java:3718)                                                                                                                   
        at org.eclipse.jdt.internal.core.builder.NameEnvironment.computeClasspathLocations(NameEnvironment.java:128)                                                                                               
        at org.eclipse.jdt.internal.core.builder.NameEnvironment.<init>(NameEnvironment.java:62)                                                                                                                   
        at org.eclipse.jdt.internal.core.builder.JavaBuilder.initializeBuilder(JavaBuilder.java:629)                                                                                                               
        at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:174)                                                                                                                           
        at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:833)                                                                                                                              
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)                                                                                                                                             
        at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:220)                                                                                                                         
        at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:263)                                                                                                                         
        at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:316)                                                                                                                              
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)                                                                                                                                             
        at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:319)                                                                                                                         
        at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:371)                                                                                                                     
        at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:392)                                                                                                                              
        at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)                                                                                                                            
        at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)                                                                                                                                
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

java.lang.NullPointerException                                                                                                                                                                                     
        at org.eclipse.jdt.internal.compiler.util.JRTUtil.walkModuleImage(JRTUtil.java:158)                                                                                                                        
        at org.eclipse.jdt.internal.core.search.indexing.AddJrtToIndex.execute(AddJrtToIndex.java:268)                                                                                                             
        at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:401)                                                                                                                     
        at java.lang.Thread.run([email protected]/Thread.java:804)

我用jdeps扫了一下,还是有没找到的包。。。

喷了,我在我自己电脑上(archlinux),按我主贴的方法用eglot,一下子就好了。。。

可能是服务器(ubuntu)的jvm有什么问题。。。