check the registry on win32 to find out where java.exe is kept

This commit is contained in:
David Vierra 2011-09-10 11:36:59 -10:00
parent 1ef73e7c16
commit a54c92d7fb

View File

@ -218,11 +218,37 @@ class MCServerChunkGenerator(object):
""" """
defaultJarStorage = None defaultJarStorage = None
if sys.platform == "win32": if sys.platform == "win32":
javaExe = which("java.exe") javaExe = which("java.exe")
javaExe = None
if javaExe is None:
KEY_NAME = "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment"
try:
p = subprocess.Popen(["REG", "QUERY", KEY_NAME, "/v", "CurrentVersion"], stdout=subprocess.PIPE, universal_newlines=True)
o, e = p.communicate()
lines = o.split("\n")
for l in lines:
l = l.strip()
if l.startswith("CurrentVersion"):
words = l.split(None, 2)
version = words[-1]
p = subprocess.Popen(["REG", "QUERY", KEY_NAME + "\\" + version, "/v", "JavaHome"], stdout=subprocess.PIPE, universal_newlines=True)
o, e = p.communicate()
lines = o.split("\n")
for l in lines:
l = l.strip()
if l.startswith("JavaHome"):
w = l.split(None, 2)
javaHome = w[-1]
javaExe = os.path.join(javaHome, "bin", "java.exe")
print "RegQuery: java.exe found at ", javaExe
break
except Exception, e:
print "Error while locating java.exe using the Registry: ", repr(e)
else: else:
javaExe = which("java") javaExe = which("java")
jarStorage = None jarStorage = None
tempWorldCache = {} tempWorldCache = {}