Principle:Apache Kafka JVM Classpath Assembly
| Knowledge Sources | |
|---|---|
| Domains | Operations, JVM_Configuration |
| Last Updated | 2026-02-09 12:00 GMT |
Overview
A classpath construction process that assembles all required JAR files from Kafka's modular build structure into a single JVM classpath.
Description
JVM Classpath Assembly scans Kafka's build output directories to collect all required JAR files into a classpath string. Kafka has a modular architecture with separate directories for core, clients, streams, tools, and Connect components. The assembly process iterates through each module's build/libs and build/dependant-libs directories, filtering out test, source, and javadoc JARs. The resulting classpath must be non-empty for the broker to start.
Usage
Use this principle when launching any Kafka JVM process. The classpath assembly ensures all required libraries are available regardless of which Kafka component is being started.
Theoretical Basis
The assembly follows a directory-scanning pattern:
- Base Directory Detection: Determine the Kafka installation root relative to the script location.
- Scala Version Resolution: Read the Scala version from gradle.properties to select version-specific JARs.
- Module Scanning: Iterate through each Kafka module directory, collecting JARs from build output.
- Filtering: Exclude test, source, and javadoc JARs unless explicitly requested via INCLUDE_TEST_JARS.
- Validation: Verify the classpath is non-empty before proceeding.