@@ -16,6 +16,9 @@ const JNI_ENOMEM = convert(Cint, -4) #/* not enough memory */
16
16
const JNI_EEXIST = convert (Cint, - 5 ) # /* VM already created */
17
17
const JNI_EINVAL = convert (Cint, - 6 ) # /* invalid arguments */
18
18
19
+ const JAVA_HOME_CANDIDATES = [" /usr/lib/jvm/default-java/" ,
20
+ " /usr/lib/jvm/default/" ]
21
+
19
22
function javahome_winreg ()
20
23
try
21
24
keypath = " SOFTWARE\\ JavaSoft\\ Java Runtime Environment"
@@ -40,19 +43,18 @@ function findjvm()
40
43
javahomes = Any[]
41
44
libpaths = Any[]
42
45
43
- if haskey (ENV ," JAVA_HOME" )
44
- push! (javahomes,ENV [" JAVA_HOME" ])
46
+ if haskey (ENV , " JAVA_HOME" )
47
+ push! (javahomes, ENV [" JAVA_HOME" ])
45
48
else
46
- @static Sys. iswindows () ? ENV [" JAVA_HOME" ] = javahome_winreg () : nothing
47
- @static Sys. iswindows () ? push! (javahomes, ENV [" JAVA_HOME" ]) : nothing
48
- end
49
-
50
- if isfile (" /usr/libexec/java_home" )
51
- push! (javahomes,chomp (read (` /usr/libexec/java_home` , String)))
49
+ @static if Sys. iswindows ()
50
+ ENV [" JAVA_HOME" ] = javahome_winreg ()
51
+ push! (javahomes, ENV [" JAVA_HOME" ])
52
+ end
52
53
end
54
+ isfile (" /usr/libexec/java_home" ) && push! (javahomes, chomp (read (` /usr/libexec/java_home` , String)))
53
55
54
- if isdir ( " /usr/lib/jvm/default-java/ " )
55
- push! (javahomes, " /usr/lib/jvm/default-java/ " )
56
+ for fname ∈ JAVA_HOME_CANDIDATES
57
+ isdir (fname) && push! (javahomes, fname )
56
58
end
57
59
58
60
push! (libpaths, pwd ())
@@ -70,8 +72,8 @@ function findjvm()
70
72
push! (libpaths, joinpath (n, " jre" , " lib" , " i386" , " server" ))
71
73
72
74
push! (libpaths, joinpath (n, " lib" , " i386" , " server" ))
73
- end
74
- end
75
+ end
76
+ end
75
77
push! (libpaths, joinpath (n, " jre" , " lib" , " server" ))
76
78
push! (libpaths, joinpath (n, " lib" , " server" ))
77
79
end
@@ -89,7 +91,7 @@ function findjvm()
89
91
Libdl. dlopen (joinpath (bindir,m[1 ]))
90
92
end
91
93
global libjvm = Libdl. dlopen (libpath)
92
- println (" Loaded $libpath " )
94
+ @debug (" Loaded $libpath " )
93
95
return
94
96
end
95
97
end
0 commit comments