Skip to content

Eclipse Java Language Server (jdtls)

Adityashaw edited this page Apr 24, 2020 · 1 revision

Eclipselsp Linter Installation Guide

If your're planning to use your package manager to install jdtls then read Notes at the end.

  • First go to https://github.com/eclipse/eclipse.jdt.ls
  • Clone the repository at your convenient place. Command to do that is
    git clone https://github.com/eclipse/eclipse.jdt.ls.git
    I have cloned it at /home/myname, so I will use this path from now on.
  • The above command will create a new directory named eclipse.jdt.ls. cd into this directory.
  • Then run ./mvnw clean verify. It will take some time to download other necessary files and then build.
  • Go to your .vimrc file (or other file you have to setup configurations for vim) and then add the following line :
    let g:ale_java_eclipselsp_path = '/home/myname/eclipse.jdt.ls'

Notes for using package manager.

I used Arch User Repository (AUR) to install jdtls but couldn't make it run with ALE. I have noticed that it has a bit different directory structure. So, I recommend to directly build from GitHub Repo, as shown in above steps.

Notes for multi-package Java Projects

Your project hierarchy may not be detected by ALE or Eclipselsp.
Follow these steps :

  1. And an empty build.gradle file in the root directory of your project. See if linting is working or not.
  2. If that doesn't help, modify the .project file in the root directory of the project(automatically created when you Lint after following Step 1. If it isn't created, you may copy the sample one attached at the end of this page.) and add all your projects :
<projects>
    <project>dir1</project>
    <project>dir2</project>
    <project>dir3</project>
    ...
    <project>dirn</project>
</projects>

That's it! Everything should be working fine. Enjoy ALE.

Sample .project file :

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>root_of_project</name>
	<projects>
		<project>package1</project>
		<project>package2</project>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
	</natures>
</projectDescription>