diff --git a/.github/workflows/pages.yaml b/.github/workflows/pages.yaml new file mode 100644 index 0000000..d181d95 --- /dev/null +++ b/.github/workflows/pages.yaml @@ -0,0 +1,41 @@ +name: Deploy GitHub Pages + +on: + push: + branches: [main] + paths: + - "docs/**" + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: true + +jobs: + deploy: + name: Deploy to GitHub Pages + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure Pages + uses: actions/configure-pages@v4 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: docs/ + + - name: Deploy + id: deployment + uses: actions/deploy-pages@v4 diff --git a/README.md b/README.md index 6dbd99d..05c8b71 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,12 @@ [![Last commit](https://img.shields.io/github/last-commit/llerandi/java-runner)](https://github.com/llerandi/java-runner/commits/main) [![Java](https://img.shields.io/badge/java-11%2B-orange?logo=openjdk)](https://openjdk.org/) [![Medium](https://img.shields.io/badge/Medium-article-black?logo=medium)](https://medium.com/@llerandi/run-any-compiled-language-without-an-ide-6d910879ac04) +[![Live site](https://img.shields.io/badge/live%20site-GitHub%20Pages-0969da)](https://llerandi.github.io/java-runner/) A command-line tool to compile and run Java exercises instantly, without an IDE, a build system, or any project structure. Point it at a `.java` file and it handles the rest. +**Live site:** [llerandi.github.io/java-runner](https://llerandi.github.io/java-runner/) + The same pattern -- wrap the compile-and-run loop into a single command, add watch mode and clean error output -- applies to any compiled language. This project implements it for Java. --- @@ -162,7 +165,15 @@ The tests cover successful runs, compilation errors, runtime errors, and missing java-runner/ ├── .github/ │ └── workflows/ -│ └── ci.yaml # GitHub Actions CI pipeline +│ ├── ci.yaml # Test pipeline (Linux, macOS, Windows) +│ └── pages.yaml # GitHub Pages deploy pipeline +├── docs/ +│ ├── diagrams/ # draw.io source files +│ ├── img/ # Exported images +│ ├── article.md # Published Medium article +│ ├── index.html # GitHub Pages site +│ ├── robots.txt +│ └── sitemap.xml ├── examples/ │ ├── HelloWorld.java # Basic output │ ├── FizzBuzz.java # Classic exercise @@ -222,11 +233,11 @@ The `examples/` folder contains three files you can use to verify the setup or a ### Phase 3 - Polish +- [x] ANSI color output on Windows +- [x] Auto-detect test added to `test.sh` and `test.bat` +- [x] GitHub Pages site with project documentation - [ ] Clear screen between runs in watch mode -- [ ] ANSI color output on Windows -- [ ] Auto-detect test added to `test.sh` and `test.bat` - [ ] `runner.ps1` using PowerShell `FileSystemWatcher` for event-based watch mode on Windows -- [ ] `article2.md` moved to `docs/`, root cleaned up ### Phase 4 - Features diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..7394808 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,465 @@ + + + + + + java-runner - Run Java files without an IDE + + + + + + + + + + + + + + + + + + + + + + +
+
+

java-runner

+

Run Java files from the terminal - no IDE required. + Source: github.com/llerandi/java-runner +

+
+ +
+ +
+ + +
+

Compile and run Java in one command

+

No IDE, no build system, no project structure. Point it at a .java file and it handles the rest.

+ +
+ + +
+
+
+
+
+
+
$ ./runner.sh FizzBuzz.java
+
 
+
▶ Compiling FizzBuzz.java...
+
✓ Compiled successfully
+
───────────────────────── output ─────────────────────────
+
1
+
2
+
Fizz
+
4
+
Buzz
+
Fizz
+
7
+
...
+
───────────────────────────────────────────────────────────
+
✓ Finished in 143ms
+
 
+
$ ./runner.sh FizzBuzz.java --watch
+
👁 Watch mode enabled - save the file to rerun
+
+ + +
+
+

Single command

+

Wraps javac and java into one step. Compiles, runs, prints output, and cleans up.

+
+
+

Watch mode

+

Reruns automatically every time you save the file. Uses inotifywait on Linux, fswatch on macOS, timestamp polling on Windows.

+
+
+

Auto file detection

+

No argument needed if there is only one .java file in the directory. Falls back to examples/ automatically.

+
+
+

Clean error output

+

Strips absolute path noise from compiler errors so they are shorter and easier to read.

+
+
+

Elapsed time

+

Shows how long the program took to run after every execution, in milliseconds.

+
+
+

Cross-platform

+

runner.sh for Linux and macOS. runner.bat for Windows. Same behavior on all three.

+
+
+ + +
+

Installation

+

Requires Java JDK 11 or higher. No other dependencies for the basic run.

+
git clone https://github.com/llerandi/java-runner.git +cd java-runner +chmod +x runner.sh
+

For watch mode on Linux, install inotify-tools:

+
sudo apt install inotify-tools
+

For watch mode on macOS, install fswatch:

+
brew install fswatch
+
+ + +
+

Usage

+
# Run a specific file +./runner.sh HelloWorld.java + +# Auto-detect if only one .java file is in the directory +./runner.sh + +# Watch mode: reruns on every save +./runner.sh HelloWorld.java --watch + +# Show help +./runner.sh --help
+

On Windows, replace ./runner.sh with runner.bat or .\runner.bat from PowerShell.

+
+ + +
+

Requirements

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ToolPurposeNotes
Java JDKCompile and runVersion 11+. Must include javac. Not just the JRE.
Bash 3.2+Run runner.shLinux and macOS only.
inotify-toolsWatch mode on Linuxsudo apt install inotify-tools
fswatchWatch mode on macOSbrew install fswatch
+
+

Windows users need no extra tools. Watch mode polls the file timestamp every 2 seconds.

+
+ + +
+

Output examples

+

Successful run:

+
+
▶ Compiling HelloWorld.java...
+
✓ Compiled successfully
+
───────────────────────── output ─────────────────────────
+
Hello, World!
+
───────────────────────────────────────────────────────────
+
✓ Finished in 98ms
+
+

Compilation error:

+
+
▶ Compiling FizzBuzz.java...
+
✗ Compilation failed:
+
 
+
FizzBuzz.java:6: error: ';' expected
+
        int x = 10
+
                   ^
+
1 error
+
+
+ +
+ + + + + + + diff --git a/docs/robots.txt b/docs/robots.txt new file mode 100644 index 0000000..03d9cdf --- /dev/null +++ b/docs/robots.txt @@ -0,0 +1,4 @@ +User-agent: * +Allow: / + +Sitemap: https://llerandi.github.io/java-runner/sitemap.xml diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 906c454..131f9a2 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -1,13 +1,18 @@ - https://github.com/llerandi/java-runner + https://llerandi.github.io/java-runner/ weekly 1.0 + + https://github.com/llerandi/java-runner + weekly + 0.9 + https://medium.com/@llerandi/run-any-compiled-language-without-an-ide-6d910879ac04 never - 0.8 + 0.7