Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Environment:Apache Flink Java Build Environment

From Leeroopedia


Knowledge Sources
Domains Infrastructure, Build_System
Last Updated 2026-02-09 13:00 GMT

Overview

Linux/macOS/Windows build environment with Java 11/17/21, Maven 3.8.6, and Scala 2.12 for compiling and running Apache Flink connector modules.

Description

This environment provides the complete Java build toolchain required to compile, test, and run the Apache Flink connector framework. The project uses Maven as its build system with a Maven Wrapper that enforces version 3.8.6. The source code targets Java 11 as the baseline language level, with Java 17 as the default compilation target. Java 21 and 25 are also supported through Maven profiles. The Scala 2.12 runtime is included for cross-language interoperability within the Flink ecosystem.

The CI environment runs on Ubuntu (Jammy) using a custom Docker image that bundles Java 8, 11, 17, and 21 alongside Maven 3.8.6. The G1 garbage collector is used for test execution with specific heap sizing per test category.

Usage

Use this environment for all build, test, and development activities on the Flink connectors codebase. This includes compiling the flink-connector-base, flink-connector-files, flink-file-sink-common, and flink-hadoop-compatibility modules. It is the mandatory prerequisite for running any of the documented Implementation pages.

System Requirements

Category Requirement Notes
OS Linux (Ubuntu 24.04 recommended), macOS, or Windows CI uses Ubuntu 24.04
Hardware x86_64 CPU ARM64 also supported
RAM 4GB minimum 3072MB allocated for max JVM heap during tests
Disk 10GB SSD For Maven repository cache and build artifacts

Dependencies

System Packages

  • Java Development Kit (JDK) 11, 17, or 21
  • Maven 3.8.6 (enforced via Maven Wrapper)
  • Git

Java Dependency Versions

  • SLF4J = 1.7.36
  • Log4j = 2.24.3
  • Jackson = 2.20.1
  • JUnit 5 = 5.11.4
  • Mockito = 5.19.0
  • ArchUnit = 1.4.1
  • Scala = 2.12.20
  • Hadoop = 2.10.2
  • Apache Beam = 2.54.0
  • ZooKeeper = 3.7.2
  • Protocol Buffers = 4.32.1
  • Flink Shaded = 21.0

Credentials

No credentials are required for building the connector modules from source. The project uses only publicly available Maven Central dependencies.

Quick Install

# Ensure JDK 17 is installed and JAVA_HOME is set
export JAVA_HOME=/path/to/jdk-17

# Clone the repository
git clone https://github.com/apache/flink.git
cd flink

# Build with Java 17 target (default)
./mvnw clean package -DskipTests -Djdk17 -Pjava17-target

# Build with Java 11 target
./mvnw clean package -DskipTests -Djdk11 -Pjava11-target

# Build with Java 21 target
./mvnw clean package -DskipTests -Djdk21 -Pjava21-target

Code Evidence

Java version configuration from `pom.xml:134-135`:

<source.java.version>11</source.java.version>
<target.java.version>17</target.java.version>

Maven version enforcement from `.mvn/wrapper/maven-wrapper.properties:18-23`:

distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip

Test JVM configuration from `pom.xml:116-129`:

<flink.XmxMax>3072m</flink.XmxMax>
<flink.XmxITCase>1536m</flink.XmxITCase>
<flink.XmxUnitTest>768m</flink.XmxUnitTest>
<flink.forkCountITCase>2</flink.forkCountITCase>
<flink.forkCountUnitTest>4</flink.forkCountUnitTest>
<flink.surefire.baseArgLine>-XX:+UseG1GC -Xms256m -XX:+IgnoreUnrecognizedVMOptions</flink.surefire.baseArgLine>

Java 17 and 21 profiles require additional compiler arguments from `pom.xml:1152-1156`:

--add-exports=java.management/sun.management=ALL-UNNAMED
--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED
--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED

Common Errors

Error Message Cause Solution
`Source option 11 is no longer supported. Use 17 or later.` JDK 25+ drops Java 11 source support Use `-Pjava21-target` or `-Pjava25-target` profile
`java.lang.module.FindException` Missing module exports on Java 17+ Ensure `--add-exports` arguments are passed via the correct Maven profile
`OutOfMemoryError` during tests Insufficient heap for forked test JVMs Increase `flink.XmxMax` or reduce `flink.forkCountUnitTest`

Compatibility Notes

  • Java 11: Fully supported as source and target. Use `-Djdk11 -Pjava11-target`.
  • Java 17: Default target. Requires `--add-exports` for internal JDK APIs used by Flink.
  • Java 21: Fully supported. Requires `--add-exports` like Java 17.
  • Java 25: Experimental support. Source level is 25; target is 25.
  • CI Docker Image: `chesnay/flink-ci:java_8_11_17_21_maven_386_jammy` bundles all supported JDKs.
  • Scala: Fixed at 2.12. No Scala 2.13 or Scala 3 support in these modules.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment