Skip to content

Commit

Permalink
docs: Update info on JDTLS install for Java (#19436)
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinegb authored and mikayla-maki committed Oct 18, 2024
1 parent 897593e commit dac0194
Showing 1 changed file with 33 additions and 47 deletions.
80 changes: 33 additions & 47 deletions docs/src/languages/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ Both use:
- Tree Sitter: [tree-sitter/tree-sitter-java](https://github.com/tree-sitter/tree-sitter-java)
- Language Server: [eclipse-jdtls/eclipse.jdt.ls](https://github.com/eclipse-jdtls/eclipse.jdt.ls)

## Pre-requisites

### Install OpenJDK
## Install OpenJDK

You will need to install a Java runtime (OpenJDK).

Expand All @@ -23,38 +21,30 @@ You will need to install a Java runtime (OpenJDK).

Or manually download and install [OpenJDK 23](https://jdk.java.net/23/).

### (Optional) Install JDTLS

If you are using Java with Eclipse JDTLS, you can skip this section as it will automatically download a binary for you.

If you are using Zed Java you need to install your own copy of Eclipse JDT Language Server (`eclipse.jdt.ls`).

- MacOS: `brew install jdtls`
- Arch: [`jdtls` from AUR](https://aur.archlinux.org/packages/jdtls)

Or manually download install:

- [JDTLS Milestone Builds](http://download.eclipse.org/jdtls/milestones/) (updated every two weeks)
- [JDTLS Snapshot Builds](https://download.eclipse.org/jdtls/snapshots/) (frequent updates)

## Extension Install

You can install either by opening {#action zed::Extensions}({#kb zed::Extensions}) and searching for `java`.

We recommend you install one or the other and not both.

## Settings / Initialization Options

Both extensions will automatically download the language server, see: [Manual JDTLS Install](#manual-jdts-install) below if you'd prefer to manage that yourself.

For available `initialization_options` please see the [Initialize Request section of the Eclipse.jdt.ls Wiki](https://github.com/eclipse-jdtls/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request).

Add the following to your Zed Settings by launching {#action zed::OpenSettings}({#kb zed::OpenSettings}).
You can add these customizations to your Zed Settings by launching {#action zed::OpenSettings}({#kb zed::OpenSettings}) or by using a `.zed/setting.json` inside your project.

### Zed Java Settings

```json
{
"lsp": {
"jdtls": {
"settings": {},
"settings": {
"version": "1.40.0", // jdtls version to download and use
"classpath": "/path/to/classes.jar:/path/to/more/classes/"
},
"initialization_options": {}
}
}
Expand All @@ -74,36 +64,8 @@ Add the following to your Zed Settings by launching {#action zed::OpenSettings}(
}
```

## See also

- [Zed Java Readme](https://github.com/zed-extensions/java)
- [Java with Eclipse JDTLS Readme](https://github.com/ABckh/zed-java-eclipse-jdtls)

## Support

If you have issues with either of these plugins, please open issues on their respective repositories:

- [Zed Java Issues](https://github.com/zed-extensions/java/issues)
- [Java with Eclipse JDTLS Issues](https://github.com/ABckh/zed-java-eclipse-jdtls/issues)

## Example Configs

### Zed Java Classpath

You can optionally configure the class path that JDTLS uses with:

```json
{
"lsp": {
"jdtls": {
"settings": {
"classpath": "/path/to/classes.jar:/path/to/more/classes/"
}
}
}
}
```

### Zed Java Initialization Options

There are also many more options you can pass directly to the language server, for example:
Expand Down Expand Up @@ -204,3 +166,27 @@ For example, to enable [Lombok Support](https://github.com/redhat-developer/vsco
}
}
```

## Manual JDTLS Install

If you prefer, you can install JDTLS yourself and both extensions can be configured to use that instead.

- MacOS: `brew install jdtls`
- Arch: [`jdtls` from AUR](https://aur.archlinux.org/packages/jdtls)

Or manually download install:

- [JDTLS Milestone Builds](http://download.eclipse.org/jdtls/milestones/) (updated every two weeks)
- [JDTLS Snapshot Builds](https://download.eclipse.org/jdtls/snapshots/) (frequent updates)

## See also

- [Zed Java Readme](https://github.com/zed-extensions/java)
- [Java with Eclipse JDTLS Readme](https://github.com/ABckh/zed-java-eclipse-jdtls)

## Support

If you have issues with either of these plugins, please open issues on their respective repositories:

- [Zed Java Issues](https://github.com/zed-extensions/java/issues)
- [Java with Eclipse JDTLS Issues](https://github.com/ABckh/zed-java-eclipse-jdtls/issues)

0 comments on commit dac0194

Please sign in to comment.