Skip to content

Commit

Permalink
Fix: Use JAVA_HOME to get the correct Java version in environment
Browse files Browse the repository at this point in the history
	•	Replaced direct java -version command with ${JAVA_HOME}/bin/java -version to ensure the Java version is fetched from the correct Java installation specified by JAVA_HOME. This improves compatibility and prevents potential issues when multiple Java versions are installed on the system.
  • Loading branch information
Asmoday committed Oct 17, 2024
1 parent 3e5a4c8 commit dd9fe84
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hadoop-ozone/dist/src/shell/ozone/ozone
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function ozonecmd_case
OZONE_MODULE_ACCESS_ARGS=""

# Get the version string
JAVA_VERSION_STRING=$(java -version 2>&1 | head -n 1)
JAVA_VERSION_STRING=$(${JAVA_HOME}/bin/java -version 2>&1 | head -n 1)

# Extract the major version number
JAVA_MAJOR_VERSION=$(echo "$JAVA_VERSION_STRING" | sed -E -n 's/.* version "([^.-]*).*"/\1/p' | cut -d' ' -f1)
Expand Down

0 comments on commit dd9fe84

Please sign in to comment.