Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
442 B
5
Indexable
Never
# Function to switch Java version
switch_java() {
  if [ "$1" == "8" ]; then
    export JAVA_HOME=/path/to/your/java8/home
  elif [ "$1" == "11" ]; then
    export JAVA_HOME=/path/to/your/java11/home
  else
    echo "Invalid argument. Usage: switch_java 8|11"
    return 1
  fi

  echo "Switched to Java $1"
  java -version
}

# Example usage:
# To switch to Java 8
# switch_java 8
# To switch to Java 11
# switch_java 11
Leave a Comment