安装OpenDaylight控制器遇JAVA_HOME相关错误求助
Alright, let's tackle this OpenDaylight installation issue you're facing—those errors are all pointing to two key problems: an incompatible Java version and missing JAVA_HOME configuration. Here's how to fix them step by step:
1. Use Java 8 (Mandatory for Beryllium)
OpenDaylight 0.4.0-Beryllium only supports Java 8—your current setup uses Java 11, which removed critical features that this older Karaf version relies on (like MaxPermSize, UnsyncloadClass, and the endorsed directories mechanism).
To install and switch to Java 8:
- Install OpenJDK 8 via apt:
sudo apt update sudo apt install openjdk-8-jdk - Set Java 8 as your default version:
When prompted, select the option corresponding tosudo update-alternatives --config java sudo update-alternatives --config javacopenjdk-8-jdk. - Verify the change:
You should see output likejava -versionopenjdk version "1.8.0_XXX".
2. Set Up JAVA_HOME Environment Variable
The error mentions JAVA_HOME not set—Karaf needs this to locate your Java installation reliably.
- First, find your Java 8 installation path (usually
/usr/lib/jvm/java-8-openjdk-amd64):update-alternatives --list java - Edit your bash profile to set the variable:
nano ~/.bashrc - Add these lines at the end of the file:
Replace the path with the one you found if it's different.export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 export PATH=$JAVA_HOME/bin:$PATH - Save and exit, then refresh your environment:
source ~/.bashrc - Verify the setup:
It should output the path you just set.echo $JAVA_HOME
3. Restart Karaf
Now run the Karaf startup command again:
sudo ./distribution-karaf-0.4.0-Beryllium/bin/karaf
This should resolve all the Java-related errors you saw earlier.
Quick Breakdown of Your Original Errors
JAVA_HOME not set; results may vary: Karaf couldn't find a consistent Java environment, leading to unpredictable behavior.- Java 11 warnings/errors: Java 11 removed support for legacy flags and mechanisms that Beryllium's Karaf build uses—downgrading to Java 8 eliminates these issues entirely.
内容的提问来源于stack exchange,提问作者Its ME




