Ubuntu 18.04.4安装Jenkins后无法启动:Java版本不符求助
First off, your installation steps are mostly applicable to Ubuntu 18.04.4—but you missed a critical step: setting Java 8 as your system's default Java runtime. That's why Jenkins is still detecting Java 10 (which older stable Jenkins versions don't support) and failing to start.
The Root Cause
From your logs, the issue is crystal clear:
Found an incorrect Java version
Java version found:
openjdk version "10.0.2" 2018-07-17
Even though you installed Oracle Java 8, your system hasn't switched to using it by default. Jenkins relies on the system's default Java executable, so it's picking up Java 10 instead of the 8 you installed.
Step-by-Step Fix
Confirm Java 8 is installed on your system:
Run this command to list all available Java versions:update-alternatives --list javaYou should see a line pointing to Oracle Java 8 (e.g.,
/usr/lib/jvm/java-8-oracle/jre/bin/java).Set Java 8 as the default runtime:
Run this command and select the number corresponding to Java 8 when prompted:sudo update-alternatives --config javaRepeat the same for the Java compiler to ensure consistency:
sudo update-alternatives --config javacVerify the default version:
Check that Java 8 is now the system default:java -version javac -versionBoth outputs should show Java 8 (Oracle or OpenJDK) instead of 10.
Restart Jenkins and check its status:
sudo systemctl restart jenkins sudo systemctl status jenkinsJenkins should now start successfully without the version mismatch error.
Alternative: Use OpenJDK 8 (Recommended for Ubuntu 18.04)
The webupd8team/java PPA is no longer maintained, so using OpenJDK 8 (officially supported in Ubuntu's base repositories) is a more stable approach:
- Uninstall Oracle Java if needed:
sudo apt remove oracle-java8-installer - Install OpenJDK 8:
sudo apt install openjdk-8-jdk - Follow steps 2-4 above to set it as default and restart Jenkins.
Content of this question is sourced from Stack Exchange, asked by Mornon.

