当前位置: 首页 > news >正文

How to install OpenJDK on Red Hat, CentOS, and Fedora

InstallingOpenJDKfrom the Red Hat-⁠family repositories gives a server or workstation theJDKtools needed to compile and runJavacode without a manual archive install. The package-⁠manager path keeps the compiler, runtime, security updates, and system-⁠wide defaults under the operating system's control.

The currentOpenJDK 21development package is java-⁠21-⁠openjdk-⁠devel onRHELand compatiblednfbased distributions. It installs javac, java, and supporting development tools under/usr/lib/jvmwhile leaving package updates to the enabledAppStreamor distribution repositories.

Choose theJDKwhen the host builds code, runs build tools that need javac, or needs development utilities such as jar and javadoc. Runtime-⁠only hosts can use the matchingJREpackage instead, and hosts with more than one majorJavarelease should usealternativesonly after the required packages are installed.

Related: How to install Java Runtime Environment (JRE) on Red Hat, CentOS Stream, and Fedora
Related: How to set JAVA_HOME on Linux
Related: How to check the installed Java version on Linux

Steps to install OpenJDK on Red Hat, CentOS, and Fedora:

  1. Open a terminal with sudo privileges.

  2. Confirm that theOpenJDK 21development package is available from the enabled repositories.
    $ dnf search --all java-21-openjdk-devel ================= Name Exactly Matched: java-21-openjdk-devel ================== java-21-openjdk-devel.x86_64 : OpenJDK 21 Development Environment

    On subscribedRHELhosts, make sure the standardAppStreamrepository is enabled before installing packages.CentOS Stream,Rocky Linux,AlmaLinux, andFedorause their equivalent enableddnfrepositories.

  3. Install theOpenJDK 21 JDKpackage.
    $ sudo dnf install --assumeyes java-21-openjdk-devel Dependencies resolved. ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: java-21-openjdk-devel x86_64 1:21.0.11.0.10-2.el9 appstream 5.0 M Installing dependencies: java-21-openjdk x86_64 1:21.0.11.0.10-2.el9 appstream 401 k java-21-openjdk-headless x86_64 1:21.0.11.0.10-2.el9 appstream 49 M Transaction Summary ================================================================================ Install 3 Packages ##### snipped ##### Complete!

    Usejava-⁠17-⁠openjdk-⁠devel,java-⁠11-⁠openjdk-⁠devel, orjava-⁠1.8.0-⁠openjdk-⁠develonly when an application specifically requires that major version. NewerFedorareleases can also provide newer non-⁠LTS packages.

  4. Verify that the compiler is installed.
    $ javac -version javac 21.0.11
  5. Verify that the runtime uses the installedOpenJDKbuild.
    $ java -version openjdk version "21.0.11" 2026-04-21 LTS OpenJDK Runtime Environment (Red_Hat-21.0.11.0.10-1) (build 21.0.11+10-LTS) OpenJDK 64-Bit Server VM (Red_Hat-21.0.11.0.10-1) (build 21.0.11+10-LTS, mixed mode, sharing)
  6. Check the installed package records if the binary versions do not match what you expected.
    $ dnf list installed java-21-openjdk-devel java-21-openjdk Installed Packages java-21-openjdk.x86_64 1:21.0.11.0.10-2.el9 @appstream java-21-openjdk-devel.x86_64 1:21.0.11.0.10-2.el9 @appstream
  7. Select the defaultJavaruntime when multiple major versions are installed.
    $ sudo alternatives --config java

    Thealternativesprompt appears only when more than one provider is installed. Repeat withsudo alternatives --config javacif the compiler default also needs to change.

http://www.jsqmd.com/news/1288795/

相关文章:

  • 物联网设备电池管理系统优化与NBM5100A解决方案
  • 炉石传说游戏体验革命:HsMod插件如何用55项功能让你的对战效率提升300%
  • 5分钟找回丢失密码:ArchivePasswordTestTool帮你轻松破解加密压缩包
  • Python期末考点精析:从基础语法到编程思维的系统梳理
  • HYPE分布式水文模型建模方法与案例分析
  • 2026气体报警器品牌5维度实力评估
  • 2026主流小程序制作平台怎么选:多端发布、零代码与长期成本对比 - 维双云小凡
  • 【题解】QOJ8672 排队
  • Function Calling 下一步:MCP 协议与 AI 工具生态
  • SPARTA开发指南:使用CMake构建跨平台空间音频插件
  • 2026年毛绒玩具定制厂商性价比排行,高性价比厂家一网打尽! - 官方资讯
  • 一张图讲清楚:Planner 如何让 Agent 先想步骤再动手
  • 小白程序员必看:医疗大模型的价值与实战指南,带你了解医疗AI的未来!
  • 2026实力之选:厦门快又好家政服务有限公司在档案规整领域的专业化路径解析 - 优企名品
  • XInputTest:游戏手柄延迟检测的终极解决方案
  • Tinke深度探索:揭秘NDS游戏资源编辑的终极工具箱
  • 2026 智能问数主流方案全景:从 Text-to-SQL 到语义层与数据 Agent
  • AG Kit工作流自动化案例:真实项目中的应用示例
  • 2026年双流区应急保电柴油发电机出租驻场运维挑选攻略 隆盛捷成等企业梳理 - 董不懂啊
  • 5分钟掌握ComfyUI智能图像分割:基于GroundingDINO和SAM的终极解决方案
  • 如何彻底解决OpenArk驱动加载问题:5步终极兼容性指南
  • QQ空间记忆会消失吗?这款免费工具帮你一键备份所有历史说说
  • GetQzonehistory:三步搞定QQ空间历史说说备份,永久保存青春记忆
  • 痛点科普:南京宠物店想做GEO优化,找哪家机构合适 - 2026最新企业资讯
  • SteamAuto:免费开源的CSGO饰品交易全自动解决方案
  • 从四个维度设计车队系统:鼎好运管人/管车/管货/管账的实现逻辑
  • Windows Defender 静默退场:no-defender 的优雅解决方案
  • 终极指南:如何使用Diablo Edit2免费修改暗黑破坏神2存档
  • [C++] 前缀函数 KMP算法
  • 华硕笔记本性能优化完整指南:G-Helper轻量级替代方案实战教程