# 使用 Homebrew, apt, apk, MacPorts, Nix, chocolatey, winget 安装 openjdk@21

查看 openjdk@21 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:openjdk@21
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install openjdk@21
```

  证据: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install openjdk21
```

  证据: MacPorts ports tree: java/openjdk21/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- Debian apt (92%):

```sh
sudo apt install openjdk-21-dbg
```

  证据: Debian stable package indexes: openjdk-21-dbg from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz

- apk (92%):

```sh
sudo apk add openjdk21
```

  证据: Alpine Linux edge package indexes: openjdk21 from https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz

- Nix (92%):

```sh
nix profile install nixpkgs#openjdk21
```

  证据: nixpkgs package indexes: openjdk21 from https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/top-level/all-packages.nix

### Windows

- Chocolatey (92%):

```sh
choco install openjdk
```

  证据: Chocolatey community package catalog: openjdk from http://community.chocolatey.org/api/v2/Packages?$filter=IsLatestVersion&$select=Id&$top=1000&$skiptoken='11','openconnect-gui'

- winget (92%):

```sh
winget install --id Microsoft.OpenJDK.17 -e
```

  证据: Windows Package Manager source index: Microsoft.OpenJDK.17 from https://cdn.winget.microsoft.com/cache/source.msix

## 软件包事实

- **软件包键:** brew:openjdk@21
- **软件包管理器:** Homebrew
- **软件包管理器页面:** <https://formulae.brew.sh/formula/openjdk@21>
- **版本:** 21.0.12
- **来源摘要:** Development kit for the Java programming language
- **主页:** <https://openjdk.org/>
- **仓库:** <https://github.com/openjdk/jdk21u>
- **上游文档:** <https://openjdk.org/>
- **许可证:** GPL-2.0-only WITH Classpath-exception-2.0
- **源码归档:** <https://github.com/openjdk/jdk21u/archive/refs/tags/jdk-21.0.12-ga.tar.gz>
- **最后更新:** 2026-07-22T10:29:57Z
- **已生成:** 2026-08-04T22:13:35+00:00

## 依赖

- freetype
- giflib
- harfbuzz
- jpeg-turbo
- libpng
- little-cms2

## 构建依赖

- autoconf
- pkgconf

## 安装行为

- post-install 钩子: 未定义
- 注意事项: For the system Java wrappers to find this JDK, symlink it with sudo ln -sfn $HOMEBREW_PREFIX/opt/openjdk@21/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-21.jdk
- Bottle: 可用 于 arm64_linux, arm64_sequoia, arm64_sonoma, arm64_tahoe, sonoma, x86_64_linux

## 版本和新鲜度

- 页面生成时间: 2026-08-04
- 管理器版本: 21.0.12
- 管理器更新时间: 2026-07-22
- 本地数据: OK
- 上游仓库: https://github.com/openjdk/jdk21u
- 信息: No cached GitHub release or tag data was available.
## 项目历史与用法

OpenJDK 21 is the open-source reference implementation of Java SE 21. It reached General Availability on 19 September 2023 and became the next major long-term-support Java line after JDK 17, with virtual threads as its headline operational feature.

### 项目历史

JDK 21 was produced by the OpenJDK JDK Project under the same time-based release model used for earlier post-Java-9 releases. The release implements Java SE 21 as specified by JSR 396 and was tracked through the JEP process.

The feature set shows how the Java platform evolved after JDK 17: virtual threads were finalized, record patterns and pattern matching for switch were delivered, sequenced collections joined the core libraries, Generational ZGC arrived, and several Panama, Amber, Vector, and structured-concurrency features remained preview or incubator work.

### 采用历史

The OpenJDK release page identifies JDK 21 as a long-term-support release from most vendors. That made it the natural upgrade candidate for teams already on Java 17 that wanted the newer concurrency model, pattern-matching improvements, and garbage-collector work without tracking every six-month feature release.

Virtual threads drove much of the ecosystem attention around JDK 21. The JEP describes them as lightweight threads intended to preserve the simple thread-per-request programming style while improving the scalability of high-throughput server applications, which made the release especially relevant to web frameworks, application servers, observability tools, and JVM operators.

### 使用方式

The package supplies the complete Java 21 developer kit: compiler, runtime, packaging tools, serviceability tools, jshell, jlink, jpackage, jwebserver, signing tools, and diagnostics. Developers install it to build and run Java 21 applications, test virtual-thread workloads, target Java 21 bytecode, and keep CI environments aligned with a named LTS release.

Operators and build engineers care about openjdk@21 because it offers a pinned Java 21 toolchain independent of the unversioned latest JDK. That is useful for reproducible Maven/Gradle builds, container base images, local development shells, and production systems that certify against a particular Java release family.

### 为什么软件包爱好者会关心

OpenJDK 21 is where a package entry is more than 'the Java package': it is a versioned runtime contract. The package lets downstream formulas, buildpacks, language servers, and CI runners ask for Java 21 specifically while other software remains on Java 17 or moves to newer feature releases.

For package nerds, the interesting bit is the coexistence problem: a modern workstation or build farm may need JDK 8 for legacy code, JDK 17 for one LTS fleet, and JDK 21 for virtual-thread-capable services. Versioned OpenJDK packages make that matrix explicit.

### 时间线

- 19 September 2023: JDK 21 reached General Availability as the Java SE 21 reference implementation.
- JDK 19 and JDK 20: virtual threads were delivered as preview features before finalization in JDK 21.
- JDK 21 release train: record patterns, pattern matching for switch, virtual threads, sequenced collections, and Generational ZGC landed in one LTS-labeled release.

### Related projects

- JDK 21 follows the JDK 17 LTS line and precedes later feature releases such as JDK 22 through JDK 25. It is also tied to OpenJDK projects such as Loom for virtual threads, Amber for language features, Panama for foreign-memory and vector work, and ZGC work in HotSpot.

### 来源

- <https://docs.oracle.com/en/java/javase/21/>
- <https://github.com/openjdk/jdk21u>
- <https://openjdk.org/jeps/444>
- <https://openjdk.org/projects/jdk/>
- <https://openjdk.org/projects/jdk/21/>


## 安全说明

没有找到 openjdk@21 的匹配本地密钥处理 manifest。软件包元数据仍在此发布，以便未来覆盖拥有稳定的软件包 URL。


## 源数据库详情

- **Source Database:** Homebrew formula API
- **Tap:** homebrew/core
- **Full Name:** openjdk@21
- **Version Scheme:** 0
- **Revision:** 0
- **Requirements:** xcode
- **Bottle Stable Root URL:** <https://ghcr.io/v2/homebrew/core>
- **Deprecated:** no
- **Disabled:** no
- **Keg Only:** yes
- **URL Keys:** stable

## 其他软件包管理器记录

- Debian apt - openjdk-21-dbg - 21.0.11+10-1~deb13u2: normalized package name match | Debian stable package indexes: openjdk-21-dbg from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Java runtime based on OpenJDK (debugging symbols) | https://openjdk.java.net/
- Debian apt - openjdk-21-demo - 21.0.11+10-1~deb13u2: normalized package name match | Debian stable package indexes: openjdk-21-demo from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Java runtime based on OpenJDK (demos and examples) | https://openjdk.java.net/
- Debian apt - openjdk-21-doc - 21.0.11+10-1~deb13u2: normalized package name match | Debian stable package indexes: openjdk-21-doc from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | OpenJDK Development Kit (JDK) documentation | https://openjdk.java.net/
- Debian apt - openjdk-21-jdk - 21.0.11+10-1~deb13u2: normalized package name match | Debian stable package indexes: openjdk-21-jdk from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | OpenJDK Development Kit (JDK) | https://openjdk.java.net/
- Debian apt - openjdk-21-jdk-headless - 21.0.11+10-1~deb13u2: normalized package name match | Debian stable package indexes: openjdk-21-jdk-headless from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | OpenJDK Development Kit (JDK) (headless) | https://openjdk.java.net/
- Debian apt - openjdk-21-jre - 21.0.11+10-1~deb13u2: normalized package name match | Debian stable package indexes: openjdk-21-jre from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | OpenJDK Java runtime, using Hotspot JIT | https://openjdk.java.net/
- Debian apt - openjdk-21-jre-headless - 21.0.11+10-1~deb13u2: normalized package name match | Debian stable package indexes: openjdk-21-jre-headless from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | OpenJDK Java runtime, using Hotspot JIT (headless) | https://openjdk.java.net/
- Debian apt - openjdk-21-jre-zero - 21.0.11+10-1~deb13u2: normalized package name match | Debian stable package indexes: openjdk-21-jre-zero from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Alternative JVM for OpenJDK, using Zero | https://openjdk.java.net/
- Debian apt - openjdk-21-source - 21.0.11+10-1~deb13u2: normalized package name match | Debian stable package indexes: openjdk-21-source from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | OpenJDK Development Kit (JDK) source files | https://openjdk.java.net/
- Debian apt - openjdk-21-testsupport - 21.0.11+10-1~deb13u2: normalized package name match | Debian stable package indexes: openjdk-21-testsupport from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Java runtime based on OpenJDK (regression test support) | https://openjdk.java.net/
- Ubuntu apt - openjdk-21-dbg - 21.0.3+9-1ubuntu1: normalized package name match | Ubuntu 24.04 LTS package indexes: openjdk-21-dbg from https://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64/Packages.gz | Java runtime based on OpenJDK (debugging symbols) | https://openjdk.java.net/
- Ubuntu apt - openjdk-21-demo - 21.0.3+9-1ubuntu1: normalized package name match | Ubuntu 24.04 LTS package indexes: openjdk-21-demo from https://archive.ubuntu.com/ubuntu/dists/noble/universe/binary-amd64/Packages.gz | Java runtime based on OpenJDK (demos and examples) | https://openjdk.java.net/
- Ubuntu apt - openjdk-21-doc - 21.0.3+9-1ubuntu1: normalized package name match | Ubuntu 24.04 LTS package indexes: openjdk-21-doc from https://archive.ubuntu.com/ubuntu/dists/noble/universe/binary-amd64/Packages.gz | OpenJDK Development Kit (JDK) documentation | https://openjdk.java.net/
- Ubuntu apt - openjdk-21-jdk - 21.0.3+9-1ubuntu1: normalized package name match | Ubuntu 24.04 LTS package indexes: openjdk-21-jdk from https://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64/Packages.gz | OpenJDK Development Kit (JDK) | https://openjdk.java.net/
- Ubuntu apt - openjdk-21-jdk-headless - 21.0.3+9-1ubuntu1: normalized package name match | Ubuntu 24.04 LTS package indexes: openjdk-21-jdk-headless from https://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64/Packages.gz | OpenJDK Development Kit (JDK) (headless) | https://openjdk.java.net/
- Ubuntu apt - openjdk-21-jre - 21.0.3+9-1ubuntu1: normalized package name match | Ubuntu 24.04 LTS package indexes: openjdk-21-jre from https://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64/Packages.gz | OpenJDK Java runtime, using Hotspot JIT | https://openjdk.java.net/


## 相关链接

- [Terminal utility packages](https://pkg.so/zh-hans/terminal-utilities/) - Matched terminal and command-line workflow metadata.
- [Developer build packages](https://pkg.so/zh-hans/developer-build-tools/) - Matched build, compiler, generator, or developer workflow metadata.
- [Language runtime packages](https://pkg.so/zh-hans/language-runtime-packages/) - Matched language runtime, compiler, or interpreter metadata.
- [Networking and protocol packages](https://pkg.so/zh-hans/networking-protocol-tools/) - Matched network, protocol, or remote-service metadata.
- [harfbuzz](https://pkg.so/zh-hans/brew/harfbuzz/) - Runtime dependency declared by Homebrew.
- [libpng](https://pkg.so/zh-hans/brew/libpng/) - Runtime dependency declared by Homebrew.
- [jpeg-turbo](https://pkg.so/zh-hans/brew/jpeg-turbo/) - Runtime dependency declared by Homebrew.
- [freetype](https://pkg.so/zh-hans/brew/freetype/) - Runtime dependency declared by Homebrew.
- [little-cms2](https://pkg.so/zh-hans/brew/little-cms2/) - Runtime dependency declared by Homebrew.
- [giflib](https://pkg.so/zh-hans/brew/giflib/) - Runtime dependency declared by Homebrew.
- [pkgconf](https://pkg.so/zh-hans/brew/pkgconf/) - Build dependency declared by Homebrew.
- [autoconf](https://pkg.so/zh-hans/brew/autoconf/) - Build dependency declared by Homebrew.
- [ghidra](https://pkg.so/zh-hans/brew/ghidra/) - Popular package that depends on this formula.
- [bazel](https://pkg.so/zh-hans/brew/bazel/) - Popular package that depends on this formula.
- [jenkins-lts](https://pkg.so/zh-hans/brew/jenkins-lts/) - Popular package that depends on this formula.
- [jmeter](https://pkg.so/zh-hans/brew/jmeter/) - Popular package that depends on this formula.
- [apache-spark](https://pkg.so/zh-hans/brew/apache-spark/) - Popular package that depends on this formula.
- [neo4j](https://pkg.so/zh-hans/brew/neo4j/) - Popular package that depends on this formula.
- [jenkins](https://pkg.so/zh-hans/brew/jenkins/) - Popular package that depends on this formula.
- [openjdk](https://pkg.so/zh-hans/brew/openjdk/) - Package name indicates the same formula family.
- [openjdk@17](https://pkg.so/zh-hans/brew/openjdk-17/) - Package name indicates the same formula family.
- [openjdk@11](https://pkg.so/zh-hans/brew/openjdk-11/) - Package name indicates the same formula family.
- [openjdk@8](https://pkg.so/zh-hans/brew/openjdk-8/) - Package name indicates the same formula family.
- [openjdk@25](https://pkg.so/zh-hans/brew/openjdk-25/) - Package name indicates the same formula family.

## Combined YAML source

View the package source record on GitHub. [combined/openjdk@21.yml](https://github.com/mxcl/pkgdb/blob/main/combined/openjdk@21.yml)


## 来源

- pkg.so package database
- package-page enrichment
- curated package history
- package version freshness
- pkgdb category and tag curation
- package relationship graph
- external package-manager database matches
- cross-ecosystem install command graph
