The extension resolves the download URL, caches the binary locally, and runs it automatically.
Setting
Default
Available Options
Description
java.format.settings.google.style
"google"
"google", "palantir"
Formatter variant. "google" supports both native-binary and jar-file modes. "palantir" is a lambda-friendly variant that requires native-binary and is unavailable on Windows and macOS x86-64.
java.format.settings.google.version
"latest"
"latest" or a release tag (e.g. "1.25.2")
Version to download. For "palantir" style, supply the Maven Central version (e.g. "2.89.0").
java.format.settings.google.mode
"native-binary"
"native-binary", "jar-file"
Runtime artifact to use. "native-binary" runs a platform-specific binary (no JVM required); for "google" style on unsupported platforms it automatically falls back to the "jar-file" JAR. "jar-file" runs the JAR via the local Java runtime and is only supported for "google" style (requires Java 21+ for google-java-format ≥ 1.22.0).
Approach 2 – Custom executable (override, not recommended)
Setting
Default
Available Options
Description
java.format.settings.google.executable
null
URL or local file path
Path or URL to a custom formatter executable. When set, style, version, and mode are all ignored.
Other Settings
Setting
Default
Available Options
Description
java.format.settings.google.extra
null
Any valid CLI flag(s)
Extra CLI arguments passed to the formatter (e.g. "--aosp" for Android Open Source Project style).
Reload the configured formatter executable (Google or Palantir) using the current configuration.
Google Java Format For VS Code: Clear Cache
Clear the local cache of formatter executable downloads (Google from GitHub Releases and Palantir from Maven Central).
How to Debug
Enable verbose logging (no code changes required)
To see exactly how the extension invokes the formatter, enable debug-level logs at
runtime:
Open the Output panel (View → Output) and pick Google Java Format For
VS Code from the drop-down. This is the extension's dedicated log channel
where every fetch, execSync, cache hit/miss, and error is printed.
To increase the log verbosity, open the Command Palette
(Ctrl+Shift+P / Cmd+Shift+P) and run Developer: Set Log Level….
⚠️ Note: this command sets the log level for the entire VS Code
application, not just this extension — setting it to Debug or Trace
will produce output from all extensions and internal VS Code services in
every Output channel. Reset it to Info (the default) afterwards to
reduce noise.
Select Debug (or Trace for maximum verbosity) and confirm. The
extension's output channel will now show detailed diagnostic messages.
Debug with breakpoints (Extension Development Host)
VS Code extensions run inside the editor's extension host process and expose two
lifecycle hooks that the runtime calls at well-defined points:
Hook
When it runs
activate(context)
Called once, lazily, the first time the extension is needed — either when VS Code opens a Java file (matching the activationEvents in package.json) or when a command contributed by this extension is invoked. All subscriptions — document format providers, commands, and configuration-change listeners — are registered here.
deactivate()
Called when the extension is explicitly disabled or when VS Code is shutting down. Use it for synchronous cleanup that must complete before the process exits.
Lazy activation explained: VS Code does not start your extension at
editor launch. activate is only called when an activation event fires
(e.g. a .java file is opened). Until that happens the extension is
dormant — no code runs, no listeners are registered.
To run the extension with breakpoints:
Open the repository in VS Code (File → Open Folder…).
Install dependencies: open a terminal and run yarn install.
Set breakpoints anywhere in src/ in the development window — for
example, at the top of activate in extension.ts or inside
provideDocumentRangeFormattingEdits.
Press F5 (or run Run → Start Debugging). VS Code compiles the
extension and launches a second Extension Development Host window with
your local build loaded.
In the host window, open or create a .java file. Opening it fires the
onLanguage:java activation event, which causes VS Code to call
activate(context) in your extension for the first time. Breakpoints
inside activate will be hit now.
Trigger formatting (Shift+Alt+F on Windows/Linux, Shift+Option+F on
macOS) to hit breakpoints inside the formatting callbacks.