Today, you can switch the Java version used in your Gitpod Terminal at any time by running sdk use java 11.0.2-open.
You can also make this change more permanent for all a project's Terminals by doing that in a Dockerfile.
However, the IDE will continue to use the old version (as described by Jens on Spectrum):
I set Java 11 as the default via sdkman in the Dockerfile. After startup of the container "java -version" and "mvn -version" are set to Java 11. Thus, I can compile and run the project with Maven in the terminal, but when I click the "Run" button above the main method in the IDE System.getProperty("java.version") somehow still returns Java 8.
It would be useful to have a way to get the IDE to use Java 11 (or any other version) too. Cc @AlexTugarev and @svenefftinge.
@svenefftinge, with the recent changes to run JDS LS in the workspace container we actually have the option to switch Java for the IDE via sdk default java 11.x.y.z. Actually it should work fine with every default setting, which may not be confused with the use setting for the current shell.
Closing, since the Gitpod's IDE will pick up the Java Version that's configured in the Workspace container (as @AlexTugarev said). A Dockerfile is the right way to install or activate the desired version of java.
How? I did the following in a DockerFIle:
FROM gitpod/workspace-full
USER root
RUN sudo apt update && \
sudo apt install -y openjdk-11-jdk && \
sudo apt-get clean && \
sudo rm -rf /var/lib/apt/lists/* && \
sudo rm -rf /var/cache/apt/* && \
The workspace does this Docker configuration. Yet, when I do java -version, the following appears:
Picked up JAVA_TOOL_OPTIONS: -Xmx3543m
openjdk version "1.8.0_202"
OpenJDK Runtime Environment (Zulu 8.36.0.1-CA-linux64) (build 1.8.0_202-b05)
OpenJDK 64-Bit Server VM (Zulu 8.36.0.1-CA-linux64) (build 25.202-b05, mixed mode)
@edsonayllon we're using SDKMAN! to configure java. Could you try to replace the apt install part with this?
RUN bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh \
&& sdk install java 11.0.2-zulufx \
&& sdk default java 11.0.2-zulufx"
Switching the default will affect the Java LS 馃憤
Worked! Thanks!