Contributions are essential for keeping this extension great. We try to keep it as easy as possible to contribute changes and we are open to suggestions for making it even easier. There are only a few guidelines that we need contributors to follow.
vscode-java is a Visual Studio Code extension that uses a language server for its Java language smartness. Usually vscode-java features depend on the Eclipse ™ JDT Language Server, (a.k.a. eclipse.jdt.ls) and the contributions should be coordinated between the two repositories.
For the whole language server to get up and running it requires two parts.
A) The Client Side (this repo): VSCode Java
B) The Server Side: JDT LS
The following will be a start to finish guide to get the entire language server up and running.
-
Install the required software:
- latest Visual Studio Code
- Node.js v4.0.0 or higher
-
Fork and clone this repository
Keep in mind the final directories will look like:
PROJECT_FOLDER/ | |--- vscode-java/ |--- eclipse.jdt.ls/
-
cd vscode-java
-
Install the dependencies:
$ npm install
This assumes that you are starting on the vscode-java
directory
-
cd ..
-
Fork and clone the eclipse.jdt.ls repository
Ensure the directory looks like:
PROJECT_FOLDER/ | |--- vscode-java/ |--- eclipse.jdt.ls/
-
Build server
$ cd ./vscode-java $ npm run build-server
*Optional:
You can run faster server builds during development by calling ./node_modules/.bin/gulp dev_server
script instead, this will build server binaries that are required by your host OS only. You can also use npm run watch-server
which will build and place them on the extension for Java changes. These commands run Maven in offline mode, so you might need to run build-server
at least once, to fetch all the dependencies.
This will build and place the binaries under the server
folder. Alternately you can download and use the latest snapshot build from Eclipse ™ JDT Language Server project with the following
$ cd ../vscode-java
$ ./node_modules/.bin/gulp download_server
Below are the details about how to set up the JDT Language Server in different IDEs. Notice: You only need set up it once in any of your preferred IDE.
-
Please install Eclipse PDE support extension in your VS Code first. The PDE extension's home page provides more usage details about Reload Target Platform, Run JUnit Plug-in Test, Run Eclipse Application.
-
Open VS Code on the
eclipse.jdt.ls
folder. The PDE extension will work with Java extension together to automatically load the eclipse.jdt.ls project. Check the status of the language tools on the lower right corner. It should show ready (thumbs up) as the image below.
-
In Eclipse, import a maven project:
Select the
eclipse.jdt.ls
folder, then click yes/accept to all following prompts: -
Now we need to use Tycho to download the dependencies, this will get rid of the errors.
At the top right arrow it will say
Set Target Platform
, select that and continue.After it will change to
Reload Target Platform
select that: -
Wait till the bottom right is done loading:
once 100%:
The errors should now be gone.
While developing the language server and the extension, you don't need to deploy the server every time to try out changes. Instead you can run the language server out of its Eclipse workspace. Currently we provide two kinds of connection modes between the extension and the language server.
-
Open VSCode on the
vscode-java
folder -
In the debug viewlet, run the launch Launch Extension - Remote Server
-
The extension will open a socket on port 3333 and will wait for the JDT language server to connect
-
With the client side (vscode-java) running, you can start the remote server in your preferred IDE.
-
In the debug console of VSCode you can see if the connection was successful.
-
When the server is running breakpoints can be reached and hot code replace can be used to make fixes without restarting the server.
-
You can modify
launch.json
to use a different port:- Modify
SERVER_PORT
to specify the port the JDT LS server should connect to.
- Modify
-
Start the language server via
jdt.ls.socket-stream
launch configuration in VS Code or Eclipse
-
Start the extenion via Launch Extension - JDTLS Client in VS Code
-
You can modify
launch.json
to use a different port:- Modify
JDTLS_CLIENT_PORT
to specify the port VS Code should connect to.
- Modify
You can create a binary that you can sideload to your VS Code installation.
-
Fork and clone this repository
-
cd vscode-java
-
Install the dependencies:
$ npm install
-
Optionally, follow the instruction to build the server.
-
See documentation on extension installation on ways to sideload or share.
If you encounter a problem and know it is caused by eclipse.jdt.ls, then please open a bug report over there. In doubt, you can report issues in the vscode-java issue tracker.
Try to collect as much informations as you can to describe the issue and help us reproduce the problem. Head over to the troubleshooting page to see how to collect useful logging informations.