Skip to content

Commit e05d08c

Browse files
feature flag
1 parent 1fd5a97 commit e05d08c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ glob = "0.3"
2626
docopt = { version = "1.1", optional = true }
2727

2828
[features]
29-
build-binary = ["docopt"]
29+
build-binary = ["docopt"]
30+
legacy-java-compat = []

src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,17 @@ fn do_locate_java_home() -> Result<String> {
195195
// Here we should have found ourselves in a directory like /usr/lib/jvm/java-8-oracle/jre/bin/java
196196
home_path.pop();
197197
home_path.pop();
198-
home_path.pop();
198+
199+
// Java 8(aka 1.8) has a slightly different directory structure,
200+
// where java is in the ${JAVA_HOME}/jre/bin/java directory, and ${JAVA_HOME}/bin/java is just a symlink.
201+
// Since we recursively follow symlinks, we end up in the wrong directory,
202+
// so we need to pop one more time.
203+
#[cfg(feature = "legacy-java-compat")]
204+
if let Some(last_section) = home_path.file_name() {
205+
if last_section == "jre" {
206+
home_path.pop();
207+
}
208+
}
199209

200210
home_path
201211
.into_os_string()

0 commit comments

Comments
 (0)