We will set up the java environment in VSCode from scratch
This is the basic toolkit, with all the base libriries and runtime. We will use AdoptOpenJDK and use the latest version, so we can test it
We of course need to grab VSCode and some of the addons.
We are going to install the full java extension pack pack by
code --install-extension vscjava.vscode-java-pack
and add support for liveshare and gradle by
code --install-extension ms-vsliveshare.vsliveshare
code --install-extension richardwillis.vscode-gradle
This is what the vaious plugin do
naco-siren.gradle-language
: support for gradlems-vsliveshare.vsliveshare
: allows for sharing the session remotelyredhat.java
: java tools for VSCode (basically the java ide)richardwillis.vscode-gradle
: Gradle tasks UIvscjava.vscode-java-debug
: Java debuggervscjava.vscode-java-dependency
: Dependency for the debuggervscjava.vscode-java-test
: Test runner for java in VSCode
such plugins can also be installed singularly, if one is so inclined.
code --install-extension naco-siren.gradle-language
code --install-extension ms-vsliveshare.vsliveshare
code --install-extension redhat.java
code --install-extension richardwillis.vscode-gradle
code --install-extension vscjava.vscode-java-debug
code --install-extension vscjava.vscode-java-dependency
code --install-extension vscjava.vscode-java-test
In order to see which plugins are installed, one can
code --list-extensions
In order to set a sepcific JDK as one in use, we are going to configure the
java.home
setting of VSCode, by
- Open VSCode settings by
ctrl+shift+P
and typePreferences: Open User Settings
- Type
java.home
in the search field - Select
Edit in settings.json
- If your VSCode state is pretty new, it could look like
{
"java.home": "C:\\Program Files\\AdoptOpenJDK\\jdk-14.0.2.12-openj9",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"telemetry.enableTelemetry": false
}
Set your java.home
to the root folder of the the jdk you want to use, like in the example
-
Reset the Java language server workspace by opening the main console
ctrl+shift+P
and looking forJava: Clean the language server workspace
and restart VSCode -
If after restart, a little hand with the tumb up appears on the bottom right of the screen, your env should be set up (sometimes you have to restart again)
-
You can check the state by gogin to the test pane and by running the tests: if the tests from purple block go to green tick mark ✔️ or red X ❌ , your env is set up.