In this post I’ll explain how you can run Java 9 workspaces in Eclipse Che.
Eclipse Che uses the Eclipse JDT (Java Development Tools) to do
all the Java language services in the IDE (code completion,
refactoring, etc…). Now that Eclipse Che is moving towards using
only LSP (Language Server Protocol) implementations it’s easier to
maintain these language services, and there is a clear separation
With Che 5.x, we had a JDT instance running on the server side. It was a custom JDT patched to get rid of all the UI that we couldn’t use in the browser-based Che IDE.
With Che 6 (usable now but due to GA in January 2018) we now have
a JDT instance packaged as part of
language server protocol implementation.
You may know already that the
was developed by Red Hat and is also used for the Java extension
on VS Code.
Language Support for Java(TM) by Red Hat - Visual Studio
_Extension for Visual Studio Code - Language Support for Java(TM) for Visual Studio Code provided by Red Hat_marketplace.visualstudio.com
It means that all improvements, bugfixes, etc. that are done
are then shared for many products — the true meaning of Christmas
However, in Eclipse Che there are a few things for Java that
aren’t part of the Language Server Protocol — these Che-specific
items have been built into the Che
Now that we had a language server compliant with Java 9 we needed
to enable it in Che. For now this work is only available through a
feature branch named
5730_Java_ls_pocin the Che repo. So I needed to build this branch and then create
Docker images for it so that others (like you) that want to try it
don’t need to checkout or build a branch!
You can skip the next section if you only want to run your workspace and aren’t interested in rebuilding Che (it’s not necessary to).
Building Che Server Docker Images
After successfully building the branch I can also make the Che server Java 9 compliant.
We could use Alpine Linux with Java 9 to have a small image but there is no OpenJDK9/Alpine yet. And it’s probably not going to happen soon based on the following issue.
As part of experimenting with stuff, let’s use Eclipse OpenJ9 — a JVM under the Eclipse Foundation (obviously we’re fans of the Foundation).
AdoptOpenJDK provides a Docker image we can use:
I’ve used the following Dockerfile to build the Che image.
In the end, I’ve successfully build the server image from the
and it’s based on the OpenJ9
Docker image. I’ve also published the image so everyone can use
Using Java 9 in my Workspace
Let’s start Eclipse Che. I’m using
as folder to store the data.
$ docker run -it –rm -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/jdtls:/data florentbenoit/che:jdtls start –fast
The output should look like:
INFO: Proxy: HTTP_PROXY=, HTTPS_PROXY=, NO_PROXY=*.local,
INFO: (che cli): jdtls - using docker 17.11.0-ce / docker4mac
INFO: (che config): Generating che configuration…
INFO: (che config): Customizing docker-compose for running in a container
INFO: (che start): Starting containers…
INFO: (che start): Services booting…
INFO: (che start): Server logs at “docker logs -f che”
INFO: (che start): Booted and reachable
INFO: (che start): Ver: jdtls
INFO: (che start): Use: http://localhost:8080
INFO: (che start): API: http://localhost:8080/swagger
We can check that the server is running Java 9:
$ docker logs 2>&1 che | grep “JVM “
- JVM Version: 9-internal+0-adhoc.jenkins.openjdk
- JVM Vendor: Eclipse OpenJ9
Great, let’s connect to http://localhost:8080 and create a new workspace.
Since this is all new work, we’ll need to create a custom Che
workspace with Java 9 installed — luckily that’s not hard! I’ve
Docker image containing OpenJDK9 on top of the
Docker image. It also includes maven.
Check that the image is set to
Also, be sure that the Java LSP agent is enabled, if it’s not you won’t get any of the language server features like code completion, etc…
You can show the config of the workspace and it should include the
(line 28 below)
When the correct Docker image is set and the Java LS agent is defined, we can start the workspace.
Let’s import a maven project from https://github.com/benoitf/jdtls-maven-example
After the project is imported, you can then try to type Java 9 code. You should have code completion and javadoc for Java 9 features.
Voilà! You can use Java 9 inside your projects now!
In the next post we’ll look at how to compile and run the Che project (as a contributor) with Java 9.
As always please let us know your thoughts by connecting with us on twitter @eclipse_che or by filing issues in the Che GitHub repo at https://github.com/eclipse/che