Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Central and the Gradle Plugin Portal. They are made with the project's release k

The key is published on [keys.openpgp.org](https://keys.openpgp.org). Import it once, then check the
checksum file of a release, and the checksum file against your download as shown on the
[Command line](get-started/command-line.md#verify-the-download) page.
[Download](get-started/command-line/download.md#verify-the-download) page.

``` sh
curl -sSL https://keys.openpgp.org/vks/v1/by-fingerprint/13A6BDF2DAA98D3D573B33EA100481FDAEE94DE9 | gpg --import
Expand Down
2 changes: 1 addition & 1 deletion docs/ai-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The four layers back each other up, so use as many as you can.
session. A `PostToolUse` hook on the `Edit` and `Write` tools runs after every file the agent
changes, and it gets the tool call as JSON on its standard input.

The hook needs `open-java-format` on the `PATH`, see [Command line](get-started/command-line.md),
The hook needs `open-java-format` on the `PATH`, see [Command line](get-started/command-line/index.md),
and [`jq`](https://jqlang.org/), which takes the path of the file out of that JSON.

``` json title=".claude/settings.json"
Expand Down
194 changes: 0 additions & 194 deletions docs/get-started/command-line.md

This file was deleted.

44 changes: 44 additions & 0 deletions docs/get-started/command-line/apt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# apt

apt installs the native binary on Ubuntu and Debian, for amd64 and arm64, and `apt upgrade` takes each
new release.

``` sh
sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://apt.openjavaformat.dev/key.asc | sudo tee /etc/apt/keyrings/open-java-format.asc > /dev/null
echo "deb [signed-by=/etc/apt/keyrings/open-java-format.asc] https://apt.openjavaformat.dev stable main" \
| sudo tee /etc/apt/sources.list.d/open-java-format.list
sudo apt update
sudo apt install open-java-format
open-java-format --version
```

The lines add our apt repository, [openjavaformat/apt](https://github.com/openjavaformat/apt), with
the key that signs it, and install the native binary of the latest release as
`/usr/bin/open-java-format`. The package needs glibc 2.34 or later: Ubuntu 22.04 or Debian 12 and
newer.

## Check the key

The repository is signed by a key of its own, not by the
[release key](../../about.md#verify-a-download) that signs the files of a GitHub release. Its
fingerprint is:

``` text
5098 A90C 44ED 5129 8CB5 C476 D8F1 EFB5 9EE1 EB3C
```

To compare it with the key you downloaded, run
`gpg --show-keys /etc/apt/keyrings/open-java-format.asc`, which prints the fingerprint without the
spaces.

## Update and hold

`sudo apt upgrade` takes each new release, at the latest an hour after it is published. A new minor
version can change the output (see [Versions](../../about.md#versions)):
`sudo apt-mark hold open-java-format` holds the installed one. The repository carries the latest
version only; older versions are binaries to [download](download.md).

## Next

[Format and check](index.md#format-and-check) shows what to run once it is installed.
68 changes: 68 additions & 0 deletions docs/get-started/command-line/download.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Download

Every release has a native binary for each platform it covers, and a runnable jar for all the rest.
Take the file by hand when none of the package managers fits: [mise](mise.md),
[Homebrew](homebrew.md), [Scoop](scoop.md) and [apt](apt.md) install the same binary and keep it
current.

Pick the file for your platform from the
[latest release](https://github.com/openjavaformat/open-java-format/releases/latest).

| Platform | File |
| --- | --- |
| Linux x86-64, glibc | `open-java-format-linux-glibc_x86-64` |
| Linux AArch64, glibc | `open-java-format-linux-glibc_aarch64` |
| macOS, Apple silicon | `open-java-format-macos_aarch64` |
| macOS, Intel | `open-java-format-macos_x86-64` |
| Windows, x86-64 | `open-java-format-windows_x86-64.exe` |
| Anything else with Java 21 or later | `open-java-format-{{ ojf_version }}-all.jar` |

The Linux binaries need glibc 2.34 or later. There is no native binary for Windows on ARM, but
Windows 11 runs the x64 one under emulation. For musl-based Linux such as Alpine there is none: use
the jar there.

## Native binary

``` sh title="Native binary, here for Apple silicon"
curl -LO https://github.com/openjavaformat/open-java-format/releases/download/{{ ojf_version }}/open-java-format-macos_aarch64
chmod +x open-java-format-macos_aarch64
./open-java-format-macos_aarch64 --version
```

Rename the file to `open-java-format`, or `open-java-format.exe` on Windows, and move it to a
directory on your `PATH`. The examples on the [Command line](index.md#format-and-check) page assume
you did.

!!! note "macOS and files downloaded with a browser"

macOS refuses to run a binary that a browser downloaded. Clear the quarantine flag first with
`xattr -d com.apple.quarantine open-java-format-macos_aarch64`. A file fetched with `curl` does
not get the flag.

## Runnable jar

``` sh title="Runnable jar"
curl -LO https://github.com/openjavaformat/open-java-format/releases/download/{{ ojf_version }}/open-java-format-{{ ojf_version }}-all.jar
java -jar open-java-format-{{ ojf_version }}-all.jar --version
```

The jar carries its dependencies and the `Add-Exports` entries the formatter needs, so it runs
without JVM flags. It needs Java 21 or later.

## Verify the download

Every release has a `checksums_sha256.txt`. Download it next to your file and check:

=== "macOS"

``` sh
shasum -a 256 --ignore-missing -c checksums_sha256.txt
```

=== "Linux"

``` sh
sha256sum --ignore-missing -c checksums_sha256.txt
```

The files are signed too: [About](../../about.md#verify-a-download) shows how to check the signature.
24 changes: 24 additions & 0 deletions docs/get-started/command-line/homebrew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Homebrew

Homebrew installs the native binary on macOS and Linux, and `brew upgrade` takes each new release.

``` sh
brew install openjavaformat/tap/open-java-format
open-java-format --version
```

The formula comes from our tap, [openjavaformat/homebrew-tap](https://github.com/openjavaformat/homebrew-tap).
It downloads the native binary of the latest release from GitHub, checks it against the release's
checksums and puts `open-java-format` on your `PATH`. It covers macOS on Apple silicon and Intel and
Linux on x86-64 and AArch64; on Windows, use [Scoop](scoop.md) or [mise](mise.md). Homebrew fetches
the file with `curl`, so macOS does not quarantine it.

## Update and hold

`brew upgrade` takes each new release, at the latest an hour after it is published. A new minor
version can change the output (see [Versions](../../about.md#versions)): `brew pin open-java-format`
holds the installed one.

## Next

[Format and check](index.md#format-and-check) shows what to run once it is installed.
Loading