Add a helper to better detect if java is installed

This commit is contained in:
amcmanu3 2023-02-14 13:59:24 -05:00
parent c434833208
commit cefa6e8084

View File

@ -15,6 +15,7 @@ import html
import zipfile
import pathlib
import ctypes
import shutil
import subprocess
import itertools
from datetime import datetime
@ -145,6 +146,24 @@ class Helpers:
logger.error(f"Unable to resolve remote bedrock download url! \n{e}")
return False
def detect_java(self):
if len(self.find_java_installs()) > 0:
return True
else:
# We'll use this as a fallback for systems
# That do not properly setup reg keys or
# Update alternatives
if self.is_os_windows():
if shutil.which("java.exe"):
return True
else:
return False
else:
if shutil.which("java"):
return True
else:
return False
@staticmethod
def find_java_installs():
# If we're windows return oracle java versions,