#!/usr/bin/env bash # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. jdk_version() { local result local java_cmd=$JAVA_HOME/bin/java local IFS=$'\n' # remove \r for Cygwin local lines=$("$java_cmd" -Xms32M -Xmx32M -version 2>&1 | tr '\r' '\n') if [[ -z $java_cmd ]] then result=no_java else for line in $lines; do if [[ (-z $result) && ($line = *"version \""*) ]] then local ver=$(echo $line | sed -e 's/.*version "\(.*\)"\(.*\)/\1/; 1q') # on macOS, sed doesn't support '?' if [[ $ver = "1."* ]] then result=$(echo $ver | sed -e 's/1\.\([0-9]*\)\(.*\)/\1/; 1q') else result=$(echo $ver | sed -e 's/\([0-9]*\)\(.*\)/\1/; 1q') fi fi done fi echo "$result" } java_version=$(jdk_version) MACHINE_TYPE=$(uname -m) jvm_arch="amd64" if [[ "${MACHINE_TYPE}" == "aarch64" ]]; then jvm_arch="aarch64" fi if [[ $java_version -gt 8 ]]; then export LIBJVM_PATH=$JAVA_HOME/lib # JAVA_HOME is jdk elif [[ -d "$JAVA_HOME/jre" ]]; then export LIBJVM_PATH=$JAVA_HOME/jre/lib/$jvm_arch # JAVA_HOME is jre else export LIBJVM_PATH=$JAVA_HOME/lib/$jvm_arch fi echo ${LIBJVM_PATH}/*/libjvm.so