9 require
"lib/mtr_misc.pl";
13 # Looks for java executable (/bin/java) in several locations:
14 # - MTR_JAVA environment variable
15 # - JAVA_HOME/bin/java
16 # - Other hard-coded locations (see below)
19 # If java executable is found, MTR_JAVA will be set to reflect this location
26 my ($key, $valuename) = @_;
27 my $cmd =
"reg query \"$key\" /v $valuename";
34 foreach my $row (@ares)
36 if($row =~ m/.*$valuename\s*REG_SZ\s*(.*)/)
51 my $key =
"HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit";
52 my $version = getRegValue($key,
"CurrentVersion");
54 if(length($version) < 1)
59 $key =
"HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\$version";
60 my $path = getRegValue($key,
"JavaHome");
69 push(@arch_paths, (
'/usr/lib/jvm/java',
'/usr/lib64/jvm/java'));
73 # Architecture dependent paths, will be expanded with -64 if we are running on 64 bit build
74 my $bits = $ENV{MYSQL_SYSTEM_ARCHITECTURE};
76 map { $_ .
"-64" } @arch_paths;
78 push(@arch_paths, (
'/usr/local/jdk',
'/usr/local/java',
'/usr/local/java/jdk'));
79 push(@arch_paths, (
'/usr/java-local/jdk-64/',
'/usr/local/jdk-64',
'/usr/local/java/jdk-64'));
81 push(@arch_paths, (
'/usr/local/jdk',
'/usr/local/java',
'/usr/local/java/jdk'));
86 my $win_path = getJavaPath();
87 if(length($win_path) > 0)
89 push(@arch_paths, $win_path);
95 my @java_paths = ($ENV{MTR_JAVA}, $ENV{JAVA_HOME}, $ENV{JDK_HOME});
97 push(@java_paths, @arch_paths);
98 push(@java_paths,
"*"); # empty path
for "java on PATH variable"
101 our $java_version =
"";
104 my ($path, $exe) = @_;
106 $exe .=
".exe" if IS_WINDOWS;
107 $path .= $pathsep
if length($path) > 0;
108 my $exists = $path . $exe;
109 my $devnull =
"/dev/null";
110 $devnull =
"NUL" if IS_WINDOWS;
112 system($exists .
" " . $java_args .
" -version > " . $devnull);
114 my $ret = $exists
if ($? == 0);
117 open(VER,
"$exists -version 2>&1 |");
118 $java_version = <VER>;
125 foreach my $path (@java_paths)
127 if (!defined $path || $path eq
'') {
131 # java on PATH env case
135 $path .= $pathsep .
"bin";
138 my $tmp = java_exists($path,
"java");
147 my $vardir = $ENV{MYSQLTEST_VARDIR} or die
"Need MYSQLTEST_VARDIR";
148 my $F = IO::File->new(
"$vardir/tmp/have_java_result.inc",
"w") or die;
149 if ($java_loc eq
'') {
150 print $F
"--skip Could not find Java executable;\n";
152 print $F
"--let \MTR_JAVA= $java_loc\n";
153 print $F
"--let \MTR_JAVA_ARGS= $java_args\n";
154 print $F
"--let \MTR_JAVA_VERSION= $java_version\n";
155 print $F
"--echo Found Java: '\$MTR_JAVA'\n";
156 print $F
"--echo Java version: '\$MTR_JAVA_VERSION'\n";
162 --source $MYSQLTEST_VARDIR/tmp/have_java_result.inc