File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -26,4 +26,5 @@ glob = "0.3"
2626docopt = { version = " 1.1" , optional = true }
2727
2828[features ]
29- build-binary = [" docopt" ]
29+ build-binary = [" docopt" ]
30+ legacy-java-compat = []
Original file line number Diff line number Diff 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 ( )
You can’t perform that action at this time.
0 commit comments