# Command line

`java [-Dcrushbalance.prefs=<dir>] -jar CrushBalance.jar [command]` (`java -cp CrushBalance.jar com.crushftp.balance.CrushBalance …` is the same). One command per call; `--x` is accepted for `-x`. `-help` prints:

```
CrushBalance 27.0.0 - TCP/TLS/HTTP load balancer for CrushMFT

Usage: java [-Dcrushbalance.prefs=<dir>] -jar CrushBalance.jar [command]

  (no command)          start; on a desktop also opens the admin page in a browser
  -d                    start without a browser (init script, Windows service)
  -check-config [file]  validate prefs.XML (or <file>) and print the findings; exit 0, or 3 on errors
  -set-admin-password   set the admin password (prompts twice; reads one line from stdin if not a terminal)
  -i [heapMB]           install or update the Windows service "CrushBalance Server" (default heap 1024 MB)
  -r                    remove the Windows service
  -version              print version information
  -help                 print this help

prefs.XML and the other files CrushBalance creates live in the prefs directory
(-Dcrushbalance.prefs=<dir>, default: the current directory).
```

- Only the server and `-set-admin-password` create a missing prefs directory (mode 0700, when its parent exists); every other command except `-version` and `-help` exits 2 when it is missing.
- `-check-config` loads keystores read-only and checks the licence; a generated certificate that does not exist yet is reported as `generated certificate will be created at first start`. It holds no lock, so it can run beside a server.
- `-version` prints the version and build time, the Java version and home, and the `prefs.XML` path; it touches no file.

**System properties:**

| Property | Meaning |
|---|---|
| `crushbalance.prefs` | The prefs directory (default: the working directory) |
| `crushbalance.service.allow_writable_dir` | `-i` only: install the service even though non-administrators can write to the folder |
| `crushbalance.service` | Set by the Windows service itself; the UI shows "Running as a Windows service" |

CrushBalance also sets `jdk.tls.rejectClientInitiatedRenegotiation=true`, some `sun.net.httpserver.*` limits of the admin server and `jdk.httpserver.maxConnections=256`, each only when you have not set it yourself.
