2018-08-09 16:37:52 -04:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
2018-07-11 12:55:18 -04:00
|
|
|
# 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.
|
|
|
|
|
2018-08-09 16:37:52 -04:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
2019-12-13 00:36:00 -05:00
|
|
|
use File::Basename;
|
2016-01-06 00:27:52 -05:00
|
|
|
|
2019-10-31 01:37:05 -04:00
|
|
|
sub fail_check {
|
|
|
|
my ($current_version) = @_;
|
|
|
|
my $current_version_text = $current_version
|
|
|
|
? "Your current version is: $current_version."
|
2022-03-04 17:15:45 -05:00
|
|
|
: "No Java runtime was detected on your system.";
|
2019-10-31 01:37:05 -04:00
|
|
|
|
|
|
|
print STDERR <<"EOT";
|
2023-07-07 15:52:35 -04:00
|
|
|
Druid requires Java 8, 11, or 17. $current_version_text
|
2019-10-31 01:37:05 -04:00
|
|
|
|
2022-03-04 17:15:45 -05:00
|
|
|
If you believe this check is in error, or you want to proceed with a potentially
|
|
|
|
unsupported Java runtime, you can skip this check using an environment variable:
|
2019-10-31 01:37:05 -04:00
|
|
|
|
|
|
|
export DRUID_SKIP_JAVA_CHECK=1
|
|
|
|
|
2023-07-07 15:52:35 -04:00
|
|
|
Otherwise, install Java 8, 11, or 17 in one of the following locations.
|
2019-12-13 00:36:00 -05:00
|
|
|
|
|
|
|
* DRUID_JAVA_HOME
|
|
|
|
* JAVA_HOME
|
|
|
|
* java (installed on PATH)
|
2022-03-04 17:15:45 -05:00
|
|
|
|
|
|
|
Other versions of Java versions may work, but are not officially supported.
|
2022-12-14 14:45:23 -05:00
|
|
|
|
|
|
|
For more information about selecting a Java runtime visit:
|
|
|
|
https://druid.apache.org/docs/latest/operations/java.html
|
2019-10-31 01:37:05 -04:00
|
|
|
EOT
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $skip_var = $ENV{'DRUID_SKIP_JAVA_CHECK'};
|
|
|
|
if ($skip_var && $skip_var ne "0" && $skip_var ne "false" && $skip_var ne "f") {
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
2019-12-13 00:36:00 -05:00
|
|
|
my $cwd = dirname(__FILE__);
|
2020-02-19 16:44:00 -05:00
|
|
|
my $java_bin_dir = `. $cwd/java-util && get_java_bin_dir 2>&1`;
|
2019-12-13 00:36:00 -05:00
|
|
|
|
|
|
|
# If we could not find java
|
|
|
|
if ($java_bin_dir eq "") {
|
|
|
|
fail_check()
|
|
|
|
}
|
|
|
|
my $java_exec = "${java_bin_dir}/java";
|
2021-07-05 09:20:36 -04:00
|
|
|
my $java_version = qx["$java_exec" -version 2>&1];
|
2018-08-09 16:37:52 -04:00
|
|
|
if ($?) {
|
2019-10-31 01:37:05 -04:00
|
|
|
fail_check();
|
2018-08-09 16:37:52 -04:00
|
|
|
}
|
2016-01-06 00:27:52 -05:00
|
|
|
|
2018-08-09 16:37:52 -04:00
|
|
|
# If we know it won't work, die. Otherwise hope for the best.
|
2023-07-07 15:52:35 -04:00
|
|
|
if ($java_version =~ /version \"((\d+)\.(\d+).*?)\"/ && !($2 == 1 && $3 == 8) && $2 != 11 && $2 != 17 ) {
|
2019-10-31 01:37:05 -04:00
|
|
|
fail_check($1);
|
2018-08-09 16:37:52 -04:00
|
|
|
}
|