No description
  • Rust 85.2%
  • Python 10.6%
  • Java 4%
  • Just 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
The Ducktor 35cc5c28da things
2026-05-01 12:41:32 +08:00
.cargo hjk 2025-11-26 10:07:59 +08:00
java-docs improve search 2025-11-16 15:42:46 +08:00
java-errors things 2026-05-01 12:41:32 +08:00
scripts things 2026-05-01 12:41:32 +08:00
src things 2026-05-01 12:41:32 +08:00
test small fixes 2026-04-30 20:28:53 +08:00
.gitignore Update .gitignore 2025-11-16 18:41:32 +08:00
build.rs first working version of error refactor 2026-05-01 09:18:52 +08:00
Cargo.lock work on errror refactor 2026-05-01 09:09:28 +08:00
Cargo.toml work on errror refactor 2026-05-01 09:09:28 +08:00
DEMO.md k 2026-01-21 08:42:13 +08:00
jfu.toml improve search 2025-11-16 15:42:46 +08:00
jfu.toml.example k 2026-01-28 08:06:41 +08:00
justfile k 2026-04-30 13:37:55 +08:00
README.md k 2026-01-28 08:06:41 +08:00
TODO.md k 2026-04-30 13:37:55 +08:00
umltest.md Create umltest.md 2026-04-30 20:50:24 +08:00

jfu - Java Fast Utility

A friendly, incremental build tool for small Java projects. No Maven. No Gradle. Just compile what you changed.

Sometimes you're working on a tiny Java project—maybe a university assignment, maybe a LeetCode warm-up, maybe just messing around—and you think "I really don't want to set up a whole Maven project for this."

But you also don't want to manually run javac in the right order every single time.

So here we are. It's not meant to replace real build tools. It's not meant to scale. It's just meant to be nice for small stuff.

What It Does

  • Incremental compilation - Only recompiles files you changed
  • Dependency tracking - Automatically builds files in the right order
  • Smart caching - Second builds are instant ⚡
  • Beautiful error messages - Java errors are less scary
  • Interactive search - Quick lookups in the Java standard library
  • JAR support - Use external libraries with glob pattern classpaths

Installation

# Build it (you need Rust)
cargo build --release

# Or run it directly
cargo run --release -- run YourFile.java

Quick Start

1. Mark your dependencies

Add a comment at the top of your Java file:

/* using "Helper.java" */

public class Main {
    public static void main(String[] args) {
        Helper.doSomething();
    }
}

2. Build and run

jfu run Main.java

That's it. It figures out the rest.

Commands

  • jfu build [file] - Compiles the file and dependencies
  • jfu run [file] - Compiles and runs the file
  • jfu tree [file] - Show the dependency tree
  • jfu clean - Remove build artifacts
  • jfu init [--force] - Create a jfu.toml config file
  • jfu search [class/method] - Search Java documentation
  • jfu search -i - Interactive search mode

Global Flags

  • -v, --verbose - Print detailed build information
  • -f, --force - Force rebuild, ignore cache
  • --auto-implicit - Automatically include all public classes in src_dir
  • --clear - Clear terminal before output
  • --watch - Watch for file changes and auto-rebuild (build/run commands only)

Configuration (jfu.toml)

jfu reads optional configuration from jfu.toml:

# Source directory containing .java files
src_dir = "."

# Output directory for compiled .class files
out_dir = "./out"

# Default entry point when none is specified
entrypoint = "Main"

# JVM options (passed to `java` command)
jvm_opts = ["-Xmx1g"]

# Automatically include implicit dependencies from same directory
auto_include_implicit_deps = false

# Clear terminal before each command run
clear_on_run = false

# Clear terminal before each auto-rebuild in watch mode
clear_on_watch_rebuild = true

# External JAR files (supports glob patterns including **)
classpath = [
    "libs/*.jar",
    "vendor/**/lib.jar"  # Recursive patterns work too
]

How It Works

  1. Reads dependency declarations - Parses /* using "..." */ comments
  2. Builds a dependency graph - Uses DFS and topological sort
  3. Checks the cache - Hashes each file to detect changes
  4. Compiles efficiently - Only rebuilds changed files
  5. Handles errors beautifully - Formats Java errors for readability

The cache is stored in .jfu/ so the second build is nearly instant.

What It Doesn't Do

  • Replace Maven/Gradle for real projects
  • Handle complex multi-module projects
  • Manage dependency versions (you download JARs yourself)
  • Scale to large codebases
  • Make your code run faster (it just compiles faster)

Troubleshooting

"File not found" errors

Problem: jfu can't find your Java file

Solutions:

  • Check that the filename matches exactly: jfu run Main.java (case-sensitive)
  • Verify the file exists: ls Main.java
  • If using non-standard directories, set src_dir in jfu.toml

Missing dependencies

Problem: Build fails with "cannot find symbol" even though you have the file

Solutions:

  • Add dependency declaration at the top of your file:
    /* using "Helper.java" */
    
  • Check for typos in filenames (case-sensitive on Linux/Mac)
  • If files are in subdirectories, use src_dir in jfu.toml
  • If you get a warning about implicit dependencies:
    ⚠️ Helper.java references classes without declaring them in header
    
    Add the missing file to the using comment

External JAR files not found

Problem: java.lang.ClassNotFoundException or classes from JARs don't compile

Solutions:

  • Add to jfu.toml:
    classpath = ["libs/*.jar"]
    
  • Download JARs into the libs/ directory
  • Use glob patterns for flexibility: vendor/**/lib*.jar
  • If it's a build-time dependency (compiling against it), it must be on the compile classpath
  • If it's a runtime dependency, it must be on the runtime classpath

Scanner/Input issues

Problem: Program hangs when trying to read input with Scanner

Solution: This is usually an issue with how jfu pipes I/O. Try:

  • Make sure your Scanner reads from System.in:
    Scanner sc = new Scanner(System.in);
    
  • If it still doesn't work, file an issue on GitHub

Pretty error messages not showing

Problem: You see raw Java compiler output instead of formatted errors

Cause: This shouldn't happen in normal use

Solution:

  • Check your terminal supports colored output: echo $TERM
  • Update to the latest version of jfu
  • If still broken, file an issue

Cache issues

Problem: Build doesn't pick up your changes, or fails unexpectedly

Solutions:

  • Clear the cache: jfu clean
  • Force rebuild: jfu -f run Main.java
  • Check if files have unexpected permissions: ls -la

Error Message Examples

Compilation Error

💥 Compilation Failed

Error #1 ───────────────────────────────────────────────
  📄 ./test/Main.java
  📍 Line 10
  💬 cannot find symbol: method doSomething()

  doSomething();
  ^

  💡 Did you mean:
    → Instead of Helper.doSomething(), try:
      • public static void doSomething()

───────────────────────────────────────────────────────────
📊 1 error

💡 Fix the errors above and try again.

Runtime Error (with stack trace)

💥 Runtime Error
─────────────────────────────────────────────────────────

  🔥 java.lang.NullPointerException: Cannot invoke method on null
    → at MyClass.process(MyClass.java:25)
    → at MyClass.main(MyClass.java:10)
    · at java.base/java.lang.reflect.Method.invoke(Method.java:580)

─────────────────────────────────────────────────────────
💡 Check the stack trace above to find the issue.

Contributing

Found a bug? Have an idea? Check out the source on GitHub and submit an issue or PR.

Credits

  • Inspired by Cargo, Rust's excellent build tool
  • Every student who's had to run javac *.java manually
  • Coffee ☕

Made for the vibes, not for production.