Skip to content

Commit 67c3846

Browse files
Fixed java extraction direcoty for mac (#644)
1 parent 54231d2 commit 67c3846

1 file changed

Lines changed: 51 additions & 8 deletions

File tree

  • Framework/install_handler/android

Framework/install_handler/android/java.py

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,29 @@ def get_java_path():
3131
if item.is_dir() and "jdk" in item.name.lower():
3232
if system == "Windows":
3333
java_exe = item / "bin" / "java.exe"
34+
elif system == "Linux":
35+
java_exe = item / "bin" / "java"
36+
elif system == "Darwin":
37+
# macOS: Check for bundle structure first (Contents/Home)
38+
contents_home = item / "Contents" / "Home"
39+
if contents_home.exists() and (contents_home / "bin" / "java").exists():
40+
java_exe = contents_home / "bin" / "java"
41+
else:
42+
# Fallback: regular directory structure
43+
java_exe = item / "bin" / "java"
3444
else:
3545
java_exe = item / "bin" / "java"
46+
3647
if java_exe.exists():
3748
return java_exe
3849

3950
# Fallback to direct bin path (if JDK was extracted directly)
4051
if system == "Windows":
4152
return jdk_dir / "bin" / "java.exe"
53+
elif system == "Linux":
54+
return jdk_dir / "bin" / "java"
55+
elif system == "Darwin":
56+
return jdk_dir / "bin" / "java"
4257
else:
4358
return jdk_dir / "bin" / "java"
4459

@@ -89,8 +104,12 @@ def update_java_path():
89104
return
90105

91106
# Get JDK home directory (parent of bin directory)
92-
# java_path is like: ~/.zeuz/zeuz_node_downloads/jdk/jdk-21/jdk-21.0.x/bin/java
93-
# jdk_home should be: ~/.zeuz/zeuz_node_downloads/jdk/jdk-21/jdk-21.0.x
107+
# java_path is like:
108+
# Linux/Windows: ~/.zeuz/zeuz_node_downloads/jdk/jdk-21/jdk-21.0.x/bin/java
109+
# macOS (bundle): ~/.zeuz/zeuz_node_downloads/jdk/jdk-21/jdk-21.0.x/Contents/Home/bin/java
110+
# jdk_home should be:
111+
# Linux/Windows: ~/.zeuz/zeuz_node_downloads/jdk/jdk-21/jdk-21.0.x
112+
# macOS (bundle): ~/.zeuz/zeuz_node_downloads/jdk/jdk-21/jdk-21.0.x/Contents/Home
94113
jdk_home = java_path.parent.parent
95114

96115
# Set JAVA_HOME for the current process
@@ -292,11 +311,35 @@ async def _extract_jdk(jdk_archive):
292311

293312
# Find the actual JDK directory (it might be nested)
294313
jdk_home = None
295-
for item in jdk_dir.iterdir():
296-
if item.is_dir() and "jdk" in item.name.lower():
297-
jdk_home = item
298-
break
299-
314+
315+
if system == "Windows":
316+
# Windows: Find JDK directory directly
317+
for item in jdk_dir.iterdir():
318+
if item.is_dir() and "jdk" in item.name.lower():
319+
jdk_home = item
320+
break
321+
elif system == "Linux":
322+
# Linux: Find JDK directory directly
323+
for item in jdk_dir.iterdir():
324+
if item.is_dir() and "jdk" in item.name.lower():
325+
jdk_home = item
326+
break
327+
elif system == "Darwin":
328+
# macOS: Handle bundle structure (Contents/Home)
329+
for item in jdk_dir.iterdir():
330+
if item.is_dir() and "jdk" in item.name.lower():
331+
# Check for macOS bundle structure: jdk_dir/Contents/Home
332+
contents_home = item / "Contents" / "Home"
333+
if contents_home.exists() and (contents_home / "bin" / "java").exists():
334+
jdk_home = contents_home
335+
break
336+
# Fallback: regular directory structure (like Linux)
337+
elif (item / "bin" / "java").exists():
338+
jdk_home = item
339+
break
340+
else:
341+
raise OSError(f"Unsupported platform: {system}")
342+
300343
if not jdk_home:
301344
print("[installer][android-jdk] Could not find JDK directory after extraction")
302345
await send_response({
@@ -309,7 +352,7 @@ async def _extract_jdk(jdk_archive):
309352
}
310353
})
311354
return None
312-
355+
313356
print(f"[installer][android-jdk] JDK extracted to {jdk_home}")
314357
return jdk_home
315358
except Exception as e:

0 commit comments

Comments
 (0)