-
Notifications
You must be signed in to change notification settings - Fork 0
/
findJRE.pl
executable file
·83 lines (78 loc) · 1.88 KB
/
findJRE.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#! /usr/bin/perl
# Attempts to finds Java VM for given system.
# This is a test for the findJRE function used by Install.pl script.
#
BEGIN {
push @INC, '.';
}
use strict;
my %VARS;
my $SYSNAME="win32";
my $BITS=64; # 32 or 64
my $TD=".";
sub findJRE {
my $abovever="1.7"; # version newer than 1.7
my @javas = ();
my %goodJRE;
my $JRE="";
my $JRE_VER="0.0";
my $jexe="jre/bin/java";
my $pgm="/usr/lib/jvm";
my $scrname="GUI/startGUI";
if ($SYSNAME eq "win32") {
$jexe="bin/java.exe";
if ($BITS eq 32) {
$pgm=sprintf("%s/Java",$ENV{'PROGRAMFILES(X86)'});
} else {
$pgm=sprintf("%s/Java",$ENV{'PROGRAMFILES'});
};
$scrname="GUI/startGUI_win32.bat";
};
#printf("pgm=%s\n",$pgm);
my @DIRS = glob("'$pgm/*'");
printf("Searching for Java VM, %d-bit:\n",$BITS);
foreach my $d (@DIRS) {
#printf("dir=%s\n",$d);
if ( -d $d ) {
my $jre=$d."/".$jexe;
if ( -f $jre) {
push @javas ,$jre;
};
};
};
foreach my $f (@javas) {
#printf("jre=%s\n",$f);
my $out=`"$f" -version 2>&1`;
my $b=32;
#printf("%s\n\n",$out);
if ( $out =~ m/version[\s\t]*"([0-9_.]+)"/) {
my $vstr=$1;
if ( $out =~ m/64[-]bit/i) {
$b=64;
};
if (($vstr > $abovever) and ($b==$BITS)) {
$goodJRE{$vstr}=$f;
};
};
};
#printf("found Java VM: \n");
for my $key (sort keys %goodJRE) {
printf("version=%-11s: %s\n",$key,$goodJRE{$key});
$JRE=$goodJRE{$key};
$JRE_VER=$key;
};
printf("\n");
if ($JRE_VER > $abovever) {
printf("Found Java VM version=%s\n%s\n\n",$JRE_VER,$JRE);
printf("You can change this choice in %s/%s.\n",$TD,$scrname);
printf("Press any key to continue ...");
<STDIN>;
$VARS{'JRE'}=$JRE;
} else {
printf("No suitable Java VM found for %s\n",$SYSNAME);
printf("You will need to define JRE maunally in %s/%s.\n",$TD,$scrname);
printf("Press any key to continue ...");
<STDIN>;
};
};
findJRE;