#!/bin/bash

JAVA_VERSION=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')
# 根据 Java 版本设置 JAVA_OPTS
if [[ $JAVA_VERSION == 17* ]]; then
    JAVA_OPTS="--add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED --add-exports java.base/jdk.internal.misc=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-exports java.base/jdk.internal.access=ALL-UNNAMED --add-exports java.base/sun.nio.cs=ALL-UNNAMED"
else
    JAVA_OPTS=""
fi
export JAVA_OPTS