Java feature: support multiple Java versions
Most of the times developer needs multiple Java versions to be installed, e.g. Java 17 is required for a Spring Tools Language Server and app itself may require Java 11. There must be a way to achieve that with "ghcr.io/devcontainers/features/java:1" feature. Currently following workaround works:
// Java 11 is required for a "Community Server Connector" (Tomcat)
"ghcr.io/devcontainers-contrib/features/tomcat-sdkman:2": {
"version": "8.5.89", // https://tomcat.apache.org/whichversion.html
"jdkVersion": "11",
"jdkDistro": "zulu"
},
// Java 17 is required for a Spring Tools Language Server
"ghcr.io/devcontainers/features/java:1": {
"version": "17",
"jdkDistro": "zulu",
"installMaven": "true",
"mavenVesion": "3.9.3" // https://maven.apache.org/docs/history.html
}
But it would be great to install multiple Java versions without installing a Tomcat. Selecting a default Java version will be also very helpful.
Hi 👋
Providing some solutions -
Option 1 - We have an experimental additionalVersions option for some of the Features to install more than one SDKs. The value specified for version option is set as default.
Can you try adding the following to .devcontainer.json?
"features": {
"ghcr.io/devcontainers/features/java:1": {
"version": "17",
"additionalVersions": "11"
}
}
Option 2 - The mcr.microsoft.com/devcontainers/universal:2 consists of Java 17 and Java 11. Maybe you could use that as the base container image?