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.cfgmissing 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
sha256sumcommand to verify your downloaded JDK tarball against the checksum provided on Oracle's website. For example:
Compare the output with the official checksum—if they don't match, re-download the package from Oracle's official page.sha256sum jdk-21_oracle-x64.tar.gz - Verify extracted directory structure: After extracting the tarball, navigate to the JDK root folder and check if
lib/jvm.cfgexists (JDK 21 uses a modular structure without a separatejrefolder). 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:
- 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 - Edit your
~/.bashrcfile to set environment variables (replacejdk-21.x.xwith your actual folder name):export JAVA_HOME=/usr/local/java/jdk-21.x.x export PATH=$JAVA_HOME/bin:$PATH - Reload the configuration with
source ~/.bashrc, then runjava --versionto confirm it works.
- Extract the downloaded tarball to a standard location like
备注:内容来源于stack exchange,提问作者Tom Quinn
相关产品推荐
相关产品推荐

