You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 20.04安装Oracle JDK 21-x64时缺失jvm.cfg文件导致java --version报错的问题咨询

Ubuntu 20.04安装Oracle JDK 21-x64时缺失jvm.cfg文件导致java --version报错的问题咨询

Hey there, sorry to hear you're stuck with this jvm.cfg missing issue while setting up Oracle JDK 21 x64 on Ubuntu 20.04. Let's break this down and get to the bottom of it.

First, a quick heads-up: jvm.cfg is a critical config file that tells the JDK which JVM implementations to load. Normally, Oracle's official JDK packages should come with this file included—so the problem is likely tied to either your installation process or the package itself.

Is this an Oracle or Ubuntu problem?

It depends entirely on how you installed the JDK:

  • If you downloaded the official Oracle JDK package directly from their site and still find jvm.cfg missing after extraction, this is almost certainly an issue with the package (maybe a corrupted download due to interruptions or CDN glitches—this is rare but can happen).
  • If you used a third-party PPA, repository, or Ubuntu-specific installer script to set up Oracle JDK, the problem is likely on the Ubuntu side (third-party sources sometimes mess up package bundling, omitting critical files like jvm.cfg).

Steps to fix and verify

Here's what you can do to resolve this:

  • Check package integrity: Use the sha256sum command to verify your downloaded JDK tarball against the checksum provided on Oracle's website. For example:
    sha256sum jdk-21_oracle-x64.tar.gz
    
    Compare the output with the official checksum—if they don't match, re-download the package from Oracle's official page.
  • Verify extracted directory structure: After extracting the tarball, navigate to the JDK root folder and check if lib/jvm.cfg exists (JDK 21 uses a modular structure without a separate jre folder). If the file is missing here, your package is corrupted.
  • Switch to manual installation (recommended): If you used a third-party source before, uninstall that version and install the official package manually:
    1. Extract the downloaded tarball to a standard location like /usr/local/java:
      sudo tar -zxvf jdk-21_oracle-x64.tar.gz -C /usr/local/java
      
    2. Edit your ~/.bashrc file to set environment variables (replace jdk-21.x.x with your actual folder name):
      export JAVA_HOME=/usr/local/java/jdk-21.x.x
      export PATH=$JAVA_HOME/bin:$PATH
      
    3. Reload the configuration with source ~/.bashrc, then run java --version to confirm it works.

备注:内容来源于stack exchange,提问作者Tom Quinn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 07:33:14