-
fix: pass headless JVM flags so macOS does not show Dock icon
发布于
2026-05-07 08:40:42 +00:00 Objective: On macOS, every CLI run pops a Java icon in the Dock and
steals focus from the active window — so any batch or repeated PDF
conversion turns into a flickering, focus-thrashing experience.Approach: Pass -Djava.awt.headless=true and -Dapple.awt.UIElement=true
as JVM args ahead of -jar at every spawn site (Node wrapper, Python
wrapper, scripts/run-cli.sh, npm export-options). The CLI never opens
a UI — it only manipulates BufferedImages and renders PDFBox pages off
screen — so headless is safe everywhere. apple.awt.UIElement is the
macOS-specific flag the launcher reads to skip Dock registration; it
is harmless on other OSes.Evidence: Ran the built jar and the Node wrapper against a sample PDF
on macOS.Before: every invocation surfaced a Java Dock icon and stole focus.
After (java -D... -jar): PDF processed, JSON written, no Dock icon.
After (Node convert() API): variant resolved successfully, no Dock icon.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
下载附件