Setting Up Java 11: JDK Options, Maven/Gradle, and IDE Configuration
Choosing a JDK Distribution
Java 11 is available from multiple OpenJDK distributions. All are TCK-certified and binary-compatible; the differences are support timelines and add-ons.
| Distribution | Vendor | Java 11 Support Until | Notes |
|---|---|---|---|
| Eclipse Temurin | Adoptium | Oct 2027 | Community standard, most downloaded |
| Amazon Corretto | Amazon | Aug 2024 (free), extended via AWS | Best choice for AWS workloads |
| Azul Zulu | Azul Systems | 2026+ | Wide platform coverage |
| Microsoft Build of OpenJDK | Microsoft | 2024 | Best for Azure |
| Oracle JDK 11 | Oracle | Oct 2024 (free LTS) | Commercial support until 2026 |
| GraalVM CE 21 | Oracle/GraalVM | Community | Native image + polyglot; JDK 21-based |
For most teams: Eclipse Temurin 11 — widest platform support, longest free support window, backed by a vendor-neutral foundation.
Installing Java 11
SDKMAN (recommended — manages multiple JDK versions)
# Install SDKMAN
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
# List available Java 11 distributions
sdk list java | grep "11\."
# Install Eclipse Temurin 11
sdk install java 11.0.22-tem
# Set as default for this project
sdk use java 11.0.22-tem
# Verify
java -version
# openjdk version "11.0.22" 2024-01-16
# OpenJDK Runtime Environment Temurin-11.0.22+7 (build 11.0.22+7)
Homebrew (macOS)
brew install --cask temurin@11
export JAVA_HOME=$(/usr/libexec/java_home -v 11)
java -version
Linux (apt — Debian/Ubuntu)
sudo apt-get update
sudo apt-get install -y temurin-11-jdk
# Or from system packages:
sudo apt-get install -y openjdk-11-jdk
Windows (winget)
winget install EclipseAdoptium.Temurin.11.JDK
Environment Variables
# Set JAVA_HOME
export JAVA_HOME=/path/to/jdk-11
export PATH=$JAVA_HOME/bin:$PATH
# Verify
java -version
javac -version
For projects that mix Java versions use SDKMAN or .sdkmanrc in the project root:
# .sdkmanrc
java=11.0.22-tem
Run sdk env install in the project directory to install and activate the pinned version.
Maven Configuration
Maven requires version 3.6.1 or later for full Java 11 support. Maven 3.8.x or 3.9.x is recommended.
Check and upgrade Maven
mvn -version
# Apache Maven 3.9.6
# If older, upgrade via SDKMAN
sdk install maven 3.9.6
Configure maven-compiler-plugin
<!-- pom.xml -->
<properties>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<configuration>
<release>11</release>
<!-- Use --release instead of source/target — it also sets the bootstrap classpath -->
</configuration>
</plugin>
</plugins>
</build>
The --release 11 flag is preferred over --source/--target because it additionally prevents use of APIs from later JDK versions, making the build more reproducible.
Enable preview features (Java 11 has none standard, but useful for testing)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<configuration>
<release>11</release>
<compilerArgs>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
Maven toolchains (for multi-JDK projects)
<!-- ~/.m2/toolchains.xml -->
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>11</version>
<vendor>temurin</vendor>
</provides>
<configuration>
<jdkHome>/path/to/jdk-11</jdkHome>
</configuration>
</toolchain>
</toolchains>
<!-- pom.xml -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<goals><goal>toolchain</goal></goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>11</version>
<vendor>temurin</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
Gradle Configuration
Gradle requires version 4.7 or later for Java 11 support. Gradle 7.x or 8.x is recommended.
Gradle wrapper setup
# Check current version
./gradlew --version
# Upgrade wrapper
./gradlew wrapper --gradle-version=8.7
build.gradle (Groovy DSL)
plugins {
id 'java'
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
// Alternatively use toolchains (preferred):
}
// Preferred: Java toolchain support (Gradle 6.7+)
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
vendor = JvmVendorSpec.ADOPTIUM // Eclipse Temurin
}
}
build.gradle.kts (Kotlin DSL)
plugins {
java
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
vendor.set(JvmVendorSpec.ADOPTIUM)
}
}
tasks.withType<JavaCompile>().configureEach {
options.release.set(11)
}
Gradle toolchain auto-provisioning
Gradle 7.6+ can auto-download the JDK if it is not found locally:
// gradle/wrapper/gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-8.7-bin.zip
// build.gradle.kts
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
// Gradle will download Temurin 11 automatically if not present
Plugin and Dependency Minimum Versions for Java 11
These library versions are the minimum required to compile and run on Java 11 (due to internal API restrictions introduced by the module system):
| Library | Minimum Version | Why |
|---|---|---|
| maven-compiler-plugin | 3.6.0 | --release flag support |
| maven-surefire-plugin | 2.22.0 | Java 11 test runner support |
| Spring Boot | 2.1.x | First version with Java 11 support |
| Hibernate | 5.3.x | First version compatible with Java 11 |
| Mockito | 2.23.0 | Bytecode generation on Java 11 |
| Byte Buddy | 1.9.0 | Module-safe bytecode manipulation |
| ASM | 7.0 | Class file version 55 (Java 11) |
| cglib | 3.2.8 | Module-safe proxy generation |
| Javassist | 3.23.1 | Java 11 compatibility |
| Jackson | 2.9.x | First version supporting Java 11 |
| JUnit 5 | 5.3.1 | Native Java 11 support |
| JUnit 4 | 4.12 | Still works with updated Surefire |
IntelliJ IDEA Configuration
Set the project SDK
- File → Project Structure → Project
- Set SDK to your Java 11 JDK installation
- Set Language level to
11 - Local variable syntax for lambda parameters - Click Apply
Set module SDK
- File → Project Structure → Modules → Dependencies
- Set Module SDK to Java 11 (or inherit from project)
Enable annotation processing (for Lombok, MapStruct)
- Preferences → Build, Execution, Deployment → Compiler → Annotation Processors
- Check Enable annotation processing
IntelliJ inspections for Java 11
IntelliJ will suggest replacing:
Paths.get()→Path.of()new ArrayList<String>()→var list = new ArrayList<String>()Collections.unmodifiableList(Arrays.asList(...))→List.of(...)
Accept these suggestions to modernise code automatically.
VS Code Configuration
Required extensions
// Install via marketplace or command palette
"vscjava.vscode-java-pack" // Java Extension Pack (includes Language Support, Debugger, Maven)
"vscjava.vscode-gradle" // Gradle for Java
Configure java.home
// .vscode/settings.json
{
"java.jdt.ls.java.home": "/path/to/jdk-11",
"java.configuration.runtimes": [
{
"name": "JavaSE-11",
"path": "/path/to/jdk-11",
"default": true
}
]
}
Per-project Java version
// .vscode/settings.json
{
"java.configuration.updateBuildConfiguration": "automatic",
"java.compile.nullAnalysis.mode": "automatic"
}
Verifying the Setup
# Compile a simple Java 11 feature to confirm everything works
cat > Test.java << 'EOF'
import java.util.List;
import java.net.http.HttpClient;
public class Test {
public static void main(String[] args) {
// var keyword (Java 10)
var list = List.of("Java", "11");
// String.isBlank() (Java 11)
list.stream()
.filter(s -> !s.isBlank())
.forEach(System.out::println);
// HTTP Client (Java 11)
var client = HttpClient.newHttpClient();
System.out.println("Setup complete. HttpClient: " + client.version());
}
}
EOF
javac --release 11 Test.java
java Test
# Java
# 11
# Setup complete. HttpClient: HTTP_2
Module System Impact on Setup
If your project uses the module system (module-info.java), Maven and Gradle need additional configuration to handle module-path compilation. For now, most projects run on the unnamed module (classpath) and require no special module configuration. Article 3 covers the full module system in depth.
What’s Next
Next: Module System (JPMS, JEP 261): Project Jigsaw Deep Dive