def _find_java_home(self):
if self._java_home:
return self._java_home
# First check if the enviornment variable is set.
java_home = os.environ.get("JAVA_HOME", None)
if java_home:
return java_home
# On OS X, there's a magical command that gives you $JAVA_HOME
if sys.platform == "darwin":
try:
cmd = sh.Command("/usr/libexec/java_home")
return cmd().strip()
except sh.ErrorReturnCode:
pass
# If only one Java is installed in the default Linux JVM folder, use
# that
if sys.platform in {"linux", "linux2"}:
if os.path.isdir(self.DEFAULT_LINUX_JVM):
javas = os.listdir(self.DEFAULT_LINUX_JVM)
if len(javas) == 1:
return javas[0]
# Give up
return None
评论列表
文章目录