Skip to content

drafael/chat4j

Repository files navigation

Chat4J

CI Security Audit License Java Maven Platforms

Lightweight desktop AI chat client built with Java 21, Swing, and Maven. Polished with FlatLaf and bundled IntelliJ themes. Chat transcripts can use native system WebViews via SwingWebView, Chromium through jcefmaven / JCEF, or a Swing fallback.

Chat4J desktop UI with light, dark, and teal themes

Quick start

mvn clean compile
mvn exec:java

Build & test

mvn clean package
mvn test

Run packaged jar:

java --enable-preview -jar target/chat4j-<version>.jar

Dependency and security audits

# Generate JaCoCo coverage report and enforce core non-UI coverage gates
mvn -Pcoverage verify

# Generate CycloneDX SBOM files in target/bom.xml and target/bom.json
mvn -Psbom verify

# Run OWASP Dependency-Check; fails on CVSS 7+
mvn -Pdependency-audit verify

# Check available dependency/plugin updates
mvn versions:display-dependency-updates versions:display-plugin-updates

Dependabot is configured in .github/dependabot.yml for Maven and GitHub Actions updates. The scheduled Security Audit workflow runs OWASP Dependency-Check weekly and uploads HTML/JSON reports.

What it does

  • Desktop chat UI (Swing + FlatLaf)
  • Multi-provider model selection
  • Streaming assistant responses
  • Local history/settings persistence (SQLite by default, optional H2, Flyway migrations)
  • Agent Mode with local workspace tools

Supported providers

API-key providers (env vars)

  • ANTHROPIC_API_KEY
  • GEMINI_API_KEY (alias: GOOGLEAI_API_KEY)
  • OPENAI_API_KEY
  • PERPLEXITY_API_KEY
  • OPENROUTER_API_KEY
  • GROQ_API_KEY
  • DEEPSEEK_API_KEY
  • MISTRAL_API_KEY
  • XAI_API_KEY

Setting environment variables

Replace sk-... with your real API key. Restart Chat4J after changing environment variables.

macOS / Linux (bash or zsh)

For the current terminal session:

export OPENAI_API_KEY="sk-..."
mvn exec:java

To make it persistent, add the export line to your shell profile:

# zsh, default on modern macOS
echo 'export OPENAI_API_KEY="sk-..."' >> ~/.zshrc

# bash
echo 'export OPENAI_API_KEY="sk-..."' >> ~/.bashrc

Reload the profile or open a new terminal:

source ~/.zshrc   # or: source ~/.bashrc

On macOS, apps launched from Finder/Dock may not inherit terminal variables. Chat4J tries to load your login shell environment, but if keys are still missing, either launch Chat4J from Terminal or set the variable for GUI apps:

launchctl setenv OPENAI_API_KEY "sk-..."

Windows PowerShell

For the current PowerShell session:

$env:OPENAI_API_KEY = "sk-..."
mvn exec:java

To make it persistent for your Windows user account:

setx OPENAI_API_KEY "sk-..."

Close and reopen PowerShell, Command Prompt, or Chat4J after running setx.

Windows Command Prompt

For the current Command Prompt session:

set OPENAI_API_KEY=sk-...
mvn exec:java

To make it persistent:

setx OPENAI_API_KEY "sk-..."

OAuth providers

  • OpenAI Codex
  • GitHub Copilot

Local providers

  • LM Studio — OpenAI-compatible server at http://localhost:1234/v1 (no API key required)
  • Ollama — OpenAI-compatible endpoint at http://localhost:11434/v1 (no API key required)

Documentation

Packaging

Native installers are built with jpackage via Maven profiles. Each profile must run on the target OS (cross-packaging is not supported).

Use OS-specific profiles:

# macOS (.dmg)
mvn -Pjpackage-mac verify

# Windows (.msi) — requires WiX Toolset 3.x
mvn -Pjpackage-win verify

# Linux (.deb) — requires dpkg
mvn -Pjpackage-linux verify

Output artifacts are written to target/dist/.

Release automation

GitHub Actions builds unsigned release artifacts for version tags and manual reruns:

git tag v26.6.13
git push origin v26.6.13

The release workflow publishes the shaded jar, macOS .dmg, Windows .msi, Linux .deb, SBOM files, and SHA-256 checksums.

License

Apache License 2.0 — see LICENSE.