Files
awesome-copilot/cookbook/copilot-sdk/java/recipe/README.md
Bruno Borges 46f6f3e6db Add Java SDK cookbook with 7 recipes
Add complete Java cookbook matching the pattern of existing .NET, Go,
Node.js, and Python cookbooks. All 7 recipes included:

- Ralph Loop: Autonomous AI task loops with JBang
- Error Handling: try-with-resources, ExecutionException, timeouts
- Multiple Sessions: Parallel sessions with CompletableFuture
- Managing Local Files: AI-powered file organization
- PR Visualization: Interactive PR age charts
- Persisting Sessions: Save/resume with custom IDs
- Accessibility Report: WCAG reports via Playwright MCP

Each recipe includes both markdown documentation and a standalone
JBang-runnable Java file in recipe/.
2026-04-06 15:20:20 -04:00

72 lines
2.4 KiB
Markdown

# Runnable Recipe Examples
This folder contains standalone, executable Java examples for each cookbook recipe. Each file can be run directly with [JBang](https://www.jbang.dev/) — no project setup required.
## Prerequisites
- Java 17 or later
- JBang installed:
```bash
# macOS (using Homebrew)
brew install jbangdev/tap/jbang
# Linux/macOS (using curl)
curl -Ls https://sh.jbang.dev | bash -s - app setup
# Windows (using Scoop)
scoop install jbang
```
For other installation methods, see the [JBang installation guide](https://www.jbang.dev/download/).
## Running Examples
Each `.java` file is a complete, runnable program. Simply use:
```bash
jbang <FileName>.java
```
### Available Recipes
| Recipe | Command | Description |
| -------------------- | ------------------------------------ | ------------------------------------------ |
| Error Handling | `jbang ErrorHandling.java` | Demonstrates error handling patterns |
| Multiple Sessions | `jbang MultipleSessions.java` | Manages multiple independent conversations |
| Managing Local Files | `jbang ManagingLocalFiles.java` | Organizes files using AI grouping |
| PR Visualization | `jbang PRVisualization.java` | Generates PR age charts |
| Persisting Sessions | `jbang PersistingSessions.java` | Save and resume sessions across restarts |
| Ralph Loop | `jbang RalphLoop.java` | Autonomous AI task loop |
| Accessibility Report | `jbang AccessibilityReport.java` | WCAG accessibility report generator |
### Examples with Arguments
**PR Visualization with specific repo:**
```bash
jbang PRVisualization.java github/copilot-sdk
```
**Managing Local Files with specific folder:**
```bash
jbang ManagingLocalFiles.java /path/to/your/folder
```
**Ralph Loop in planning mode:**
```bash
jbang RalphLoop.java plan 5
```
## Why JBang?
JBang lets you run Java files as scripts — no `pom.xml`, no `build.gradle`, no project scaffolding. Dependencies are declared inline with `//DEPS` comments and resolved automatically.
## Learning Resources
- [JBang Documentation](https://www.jbang.dev/documentation/guide/latest/)
- [GitHub Copilot SDK for Java](https://github.com/github/copilot-sdk-java)
- [Parent Cookbook](../README.md)