imbajin commented on code in PR #2846:
URL: 
https://github.com/apache/incubator-hugegraph/pull/2846#discussion_r2253310648


##########
hugegraph-pd/hg-pd-dist/src/assembly/static/bin/start-hugegraph-pd.sh:
##########
@@ -79,7 +79,15 @@ fi
 
 # check jdk version
 JAVA_VERSION=$($JAVA -version 2>&1 | awk 'NR==1{gsub(/"/,""); print $3}'  | 
awk -F'_' '{print $1}')
-if [[ $? -ne 0 || $JAVA_VERSION < $EXPECT_JDK_VERSION ]]; then
+
+if [[ $JAVA_VERSION == 1.* ]]; then
+    MAJOR_VERSION=$(echo $JAVA_VERSION | cut -d'.' -f2)
+else
+    MAJOR_VERSION=$(echo $JAVA_VERSION | cut -d'.' -f1)
+fi
+
+
+if [[ $? -ne 0 || $MAJOR_VERSION -lt $EXPECT_JDK_VERSION ]]; then
     echo "Please make sure that the JDK is installed and the version >= 
$EXPECT_JDK_VERSION"  >> ${OUTPUT}
     exit 1

Review Comment:
   The logic need to refactor like
   ```bash
   #!/bin/bash
   # Expected JDK version
   EXPECT_JDK_VERSION=11
   
   # Extract and check Java version
   JAVA_VERSION=$(java -version 2>&1 | head -n1 | sed -n 's/.*version 
"\([0-9]*\)\..*/\1/p')
   
   if [[ "$JAVA_VERSION" != "$EXPECT_JDK_VERSION" ]]; then
       echo "Expected Java ${EXPECT_JDK_VERSION}, but found Java 
${JAVA_VERSION} ✗"
   fi
   ```
   
   And test it 
   <img width="748" height="482" alt="image" 
src="https://github.com/user-attachments/assets/987dc4d0-81ff-4ddb-9036-3b5cfdeaed0f";
 />
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@hugegraph.apache.org
For additional commands, e-mail: issues-h...@hugegraph.apache.org

Reply via email to