{"id":50657617,"url":"https://github.com/nthnn/kantanj","last_synced_at":"2026-06-08T00:31:34.681Z","repository":{"id":326462049,"uuid":"1105642876","full_name":"nthnn/kantanj","owner":"nthnn","description":"Small single-file C utility that helps you create, build, run and manage minimal Java Maven projects from the command line.","archived":false,"fork":false,"pushed_at":"2025-11-28T08:35:52.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-30T13:17:34.623Z","etag":null,"topics":["java-build","java-builder","java-project","maven","maven-repository"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nthnn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-28T00:02:30.000Z","updated_at":"2025-11-28T08:35:56.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/nthnn/kantanj","commit_stats":null,"previous_names":["nthnn/kantanj"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/nthnn/kantanj","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nthnn%2Fkantanj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nthnn%2Fkantanj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nthnn%2Fkantanj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nthnn%2Fkantanj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nthnn","download_url":"https://codeload.github.com/nthnn/kantanj/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nthnn%2Fkantanj/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34043822,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java-build","java-builder","java-project","maven","maven-repository"],"created_at":"2026-06-08T00:31:34.022Z","updated_at":"2026-06-08T00:31:34.665Z","avatar_url":"https://github.com/nthnn.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kantanj\n\n`kantanj` is a small, single-file C utility that helps you create, build, run and manage minimal Java (Maven) projects from the command line. It was designed as a pragmatic, portable replacement for a shell helper script: it detects Java via `which java`, corrects `JAVA_HOME` when necessary, creates a basic Maven `pom.xml` and a starter `App.java`, and wraps `mvn` for building and running.\n\n---\n\n## Installation\n\n```sh\ncurl -fsSL https://raw.githubusercontent.com/nthnn/kantanj/refs/heads/main/install.sh | bash\n```\n\n---\n\n## Features\n\n* Create a minimal Maven project (pom + `src/main/java/.../App.java`) from a package name.\n* Build the project with Maven (executes `mvn -DskipTests package`).\n* Run the project's JAR (builds automatically if needed).\n* Clean the project's `target` directory.\n* Best-effort install helper to install JDK 21 and Maven via `apt` (Debian/Ubuntu).\n* Detects Java via `which java` and computes the correct `JAVA_HOME` (fixes cases when `JAVA_HOME` was incorrectly set to the `java` binary).\n* Small, portable C code (single translation unit).\n\n---\n\n## Requirements\n\n* Linux (tested on Debian/Ubuntu-like systems). Many utilities rely on standard Unix tools.\n* `gcc` (to build `kantanj.c`) or any compatible C compiler.\n* `mvn` (Apache Maven) — `kantanj` can attempt to install Maven via `apt` when using `install` command.\n* `java` — a JDK (OpenJDK/Temurin) is required to build and run projects. `kantanj` attempts to detect and fix `JAVA_HOME` where possible.\n\n\u003e Note: The built-in `install` command attempts `apt` installs and Adoptium repo steps; it is not guaranteed to work for all distros. If your distro is not Debian/Ubuntu-based, install Java and Maven using your platform package manager.\n\n---\n\n## Quick start\n\n1. Build the program:\n\n```bash\ngcc -O2 -std=c11 -Wall -Wextra -o kantanj kantanj.c\n```\n\n2. (Optional) Install to `/usr/local/bin`:\n\n```bash\nsudo install -m 0755 kantanj /usr/local/bin/kantanj\n```\n\n3. Create a project:\n\n```bash\nkantanj create helloworld com.example.hello\n```\n\n4. Build:\n\n```bash\nkantanj build helloworld\n```\n\n5. Run:\n\n```bash\nkantanj run helloworld arg1 arg2\n```\n\n6. Clean:\n\n```bash\nkantanj clean helloworld\n```\n\n---\n\n## Commands \u0026 examples\n\n```\nUsage: kantanj \u003ccommand\u003e [args]\nCommands:\n  install                    Install JDK 21 and Maven (attempt via apt)\n  create \u003cname\u003e \u003cpackage\u003e    Create a basic maven project (e.g. com.example)\n  build \u003cname\u003e               Build project using mvn (uses ~/.m2/settings.xml)\n  run \u003cname\u003e [args...]       Run project's jar (builds if needed)\n  clean \u003cname\u003e               Remove project's target directory\n```\n\n### Examples\n\nCreate a project `helloworld` with package `com.example.hello`:\n\n```bash\nkantanj create helloworld com.example.hello\n```\n\nThis creates:\n\n```\nhelloworld/\n  pom.xml\n  src/main/java/com/example/hello/App.java\n```\n\nThe `pom.xml` will use `groupId = com.example.hello` and `artifactId = helloworld`. The main class will be `com.example.hello.App`.\n\nBuild:\n\n```bash\nkantanj build helloworld\n```\n\nRun (passes args to Java program):\n\n```bash\nkantanj run helloworld foo bar\n```\n\nClean:\n\n```bash\nkantanj clean helloworld\n```\n\nInstall prerequisites (try to install JDK 21 + Maven via apt; may prompt for `sudo`):\n\n```bash\nsudo kantanj install\n```\n\nor, from non-root:\n\n```bash\nkantanj install\n```\n\n`kantanj` will try to use `sudo` when needed.\n\n---\n\n## How `JAVA_HOME` is handled\n\nMany Java tools (including Maven) expect `JAVA_HOME` to refer to the **JDK home directory** (for example `/usr/lib/jvm/temurin-21-jdk-amd64`), not to the `java` binary itself.\n\n`kantanj`:\n\n1. Detects Java using `which java` (so it follows the user's PATH).\n2. Resolves symlinks with `realpath`.\n3. Converts the path of the `java` binary to a reasonable `JAVA_HOME` (if `.../bin/java` is detected, it uses the parent directory as `JAVA_HOME`).\n4. Sets `JAVA_HOME` for the process that runs Maven (so `mvn` sees a valid `JAVA_HOME` even if the environment was set wrongly).\n\nThis approach fixes the common situation where `JAVA_HOME` is accidentally set to `/usr/lib/jvm/temurin-21-jdk-amd64/bin/java` (binary) instead of `/usr/lib/jvm/temurin-21-jdk-amd64` (home).\n\n---\n\n## Development / Build\n\nBuild locally:\n\n```bash\ngcc -O2 -std=c11 -Wall -Wextra -o kantanj kantanj.c\n```\n\nTurn on more warnings (optional):\n\n```bash\ngcc -O2 -std=c11 -Wall -Wextra -Wpedantic -o kantanj kantanj.c\n```\n\nRun the program locally without installing:\n\n```bash\n./kantanj create myproject com.example.myproj\n./kantanj build myproject\n././kantanj run myproject\n```\n\nIf changes are made and you want to install the binary:\n\n```bash\nsudo install -m 0755 kantanj /usr/local/bin/kantanj\n```\n\n---\n\n## Design \u0026 implementation notes\n\n* `kantanj.c` is a single C file intentionally kept self-contained for simplicity.\n* The program uses `system()` for a few operations (e.g. calling `mvn`, `apt-get`, or `rm -rf`). This keeps the code straightforward, but be mindful of shell injection if you integrate the tool into other automated flows — do not pass untrusted data into `kantanj` commands that would be composed into shell commands.\n* File writing and directory creation are implemented in C (no shell required).\n* `create` writes a minimal `pom.xml` with `maven-shade-plugin` configured so `package` produces an executable fat JAR.\n* `install` attempts `apt` installs and a best-effort attempt to add the Adoptium apt repo. It does **not** implement tarball extraction and full `update-alternatives` registration. If `install` fails, install JDK/Maven manually for your platform.\n\n---\n\n## Troubleshooting\n\n**`The JAVA_HOME environment variable is not defined correctly`** (Maven error)\n\n* This means `JAVA_HOME` points to a path Maven does not accept (commonly the `java` binary). `kantanj` attempts to detect and correct `JAVA_HOME` automatically. To verify:\n\n  ```bash\n  which java\n  realpath $(which java)\n  echo $JAVA_HOME\n  ```\n* If `echo $JAVA_HOME` prints something ending with `/bin/java`, correct it:\n\n  ```bash\n  export JAVA_HOME=/usr/lib/jvm/temurin-21-jdk-amd64\n  ```\n\n  Then re-run `kantanj build ...`.\n\n**Maven download failures (network / 502s)**\n\n* `kantanj` writes a minimal `~/.m2/settings.xml` that mirrors central to `repo1.maven.org`. If your environment uses a corporate proxy or internal mirror, adjust `~/.m2/settings.xml` accordingly.\n\n**`apt` install fails on non-Debian systems**\n\n* The `install` command targets Debian/Ubuntu. For other distros, use the distro's package manager (dnf, yum, pacman, zypper) or install a JDK manually.\n\n---\n\n## License\n\nCopyright 2025 - Nathanne Isip\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n---\n\n## Changelog\n\n* `v0.1` — initial single-file C implementation:\n\n  * `create`, `build`, `run`, `clean` commands.\n  * `install` helper (apt-focused).\n  * `JAVA_HOME` auto-correction (computed from `which java`).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnthnn%2Fkantanj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnthnn%2Fkantanj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnthnn%2Fkantanj/lists"}