jbx
jbx is a Rust-native Java toolbox: JBang-compatible script running, Maven tool execution, testing, formatting, publishing, cache management, and JDK handling behind one CLI.
|
|
The installer downloads a native release binary for Linux or macOS; Rust is only needed when building from source.
This repository is intentionally aiming for JBang compatibility rather than inventing a new script format.
Current slice
Implemented now:
jbx run <script.java> [args...]jbx build <script.java>jbx check [path...]checks Java source files/directories with javac-Xlint:alland Error Prone by defaultjbx init <script.java>built-in Java template generationjbx template list [--json]list built-in and imported catalog init templatesjbx cache clearjbx cache path [--cache-dir ...]jbx cache list [--json] [--cache-dir ...]jbx trust add|remove|list|clearfor remote script trust entriesjbx run --trust <http(s)://.../script.java>/jbx build --trust <http(s)://.../script.java>jbx app install <script.java>install a script as a PATH commandjbx app uninstall <name>remove an installed commandjbx app listlist installed script commandsjbx alias list [--json]list aliases from the nearestjbang-catalog.jsonjbx alias add <script.java|url> [args...]add a local catalog aliasjbx alias remove <name>remove a local catalog aliasjbx catalog add <name> <catalog-path-or-url> [--import]register an external catalogjbx catalog list [--json]list external catalogs from the nearestjbang-catalog.jsonjbx run <alias>/jbx <alias>run local catalog aliasesjbx test [script.java|directory]run JUnit tests with the standalone console launcherjbx fmt [path...]format Java files with Palantir Java Format, including Java 25 compact scriptsjbx graph dump <script.java>print JavaParser's native AST JSON serializationjbx graph import <ast.json> [-o script.java]convert JavaParser's native AST JSON serialization back to Java sourcejbx export local <script.java|alias> [-o app.jar]export a runnable JAR with local manifest classpathjbx export portable <script.java|alias> [-o app.jar]export a runnable JAR pluslib/dependenciesjbx export native <script.java|alias> [-o app]export a native executable via GraalVMnative-imagejbx publish [script.java] --file jbx.json --dry-runprepares a Maven Central bundle ZIP using flatgroup/id/versionmetadata;--versionoverrides the descriptor versionjbx publish [script.java] --file jbx.json --publishsigns the artifacts, uploads the bundle through the Maven Central Portal API, and waits for publicationjbx publish [script.java] --file jbx.json --serve <port>serves the prepared artifact from a local Maven-compatible HTTP repositoryjbx install [script.java] --file jbx.json [--destination repo]installs the artifact into a Maven repository layout; default destination is~/.m2/repositoryjbx skill listlists version-matched agent skills bundled with this jbx releasejbx skill get [name]prints a bundled agent skill; defaults to the mainjbxskilljbx docs <GAV|source|dir> [--json]prints agent-friendly documentation; remotegroup:artifactresolves the latest release before fetching sidecars, remote GAV sidecars are cached, local sources are generated freshjbx info classpath <script.java>jbx info tools <script.java>with--selectjbx info docs <script.java>jbx info cache [--cache-dir ...]jbx info main|java|description|gav|module <script.java>jbx info deps|repos|sources|files <script.java>jbx info compile-options|runtime-options|native-options|javaagents|manifest <script.java>jbx <GAV|script.java> [args...]run a Java script or Maven executable tooljbx --main <class> <GAV> -- [args...]run a main class with the resolved classpathjbx search [text|group:artifact[:version]] [--group G] [--id A] [--limit N] [--json]search Maven Central artifacts- directive parsing for:
//JAVA//DEPS//REPOS//SOURCES//FILES//PREVIEW//JAVAC_OPTIONS///COMPILE_OPTIONS//RUNTIME_OPTIONS///JAVA_OPTIONS//MAIN//DESCRIPTION//GAV//MODULE//DOCS//MANIFEST//JAVAAGENT//NATIVE_OPTIONS//CDS//NOINTEGRATIONS
- compile/run cache under the OS cache directory
jbx buildcompiles scripts into cache without running themjbx initcreates Java 25+ unnamed-class scripts from built-in or imported catalog templates (hello/java,compact,cli,agent, plus catalogtemplatesentries), supports--deps,--java,--template, and--forcejbx template listlists built-in and imported catalog init templates and supports--jsonjbx cache clearclears the compiled-script cachejbx cache pathprints the effective compiled-script cache directoryjbx cache listlists cached script entries with their classes/cache directories and supports--jsonjbx trust add <url>stores the current remote script content hashjbx trust list,remove, andclearmanage trusted remote script entries- remote
http://andhttps://scripts are downloaded into cache and require matching trust before build/run unless--trustis passed - remote relative
//SOURCES, source-like//DEPS, and//FILESresources are downloaded next to the cached remote script - remote trust hashes cover those downloaded resources
jbx info classpathprints the script runtime classpath, with--deps-onlyjbx info toolsprints JSON metadata for tooling and supports selecting a single fieldjbx info docsprints description and documentation referencesjbx info main,java,description,gav, andmoduleprint single metadata valuesjbx info deps,repos,sources, andfilesprint directive collections one-per-linejbx info compile-options,runtime-options,native-options,javaagents, andmanifestprint advanced directive collectionsjbx info cacheprints the effective cache directory- CLI overrides for
--deps,--repo,--source,--files,--java,--main,--compile-option,--java-option, and--javaagent - local and imported catalog aliases from
jbang-catalog.json/.jbang/jbang-catalog.json, includingalias add/remove,catalog add/list,base-ref,script-ref,catalog-ref,import,arguments,dependencies,repositories,sources,files, classpaths, Java/runtime/compile options, agents, Java version, and main-class metadata - imported catalog templates with
file-refsand defaultproperties, usable viajbx init --template <name> jbx export localcreates runnable JARs whose manifest classpath points at local dependency pathsjbx export portablecreates runnable JARs and copies file-based dependency classpath entries into siblinglib/jbx export nativecompiles scripts then invokes GraalVMnative-image, passing//NATIVE_OPTIONSplus--native-optionvaluesjbx publish --dry-runreadsjbx.jsonby default, accepts flatgroup/id/versionmetadata, supports--versionoverrides, compiles/stages all declared Java sources including compact unnamed-class scripts, and writes a Maven repository-layout Central bundle with main, sources, generated javadoc when possible, POM,-jbx-docs.md/-jbx-docs.jsonsidecars, and required checksum artifactsjbx publish --publishuploads the signed Central bundle to the Portal API withpublishingType=AUTOMATICby default and polls/api/v1/publisher/statusuntil it isPUBLISHEDorFAILEDjbx publish --serve <port>prepares the same Maven repository layout unsigned and serves it fromhttp://127.0.0.1:<port>/; port0asks the OS to choose a free port; it also serves artifact-levelmaven-metadata.xmlplus checksums so version-less Maven lookups workjbx installinstalls the current project into~/.m2/repositoryby default or another Maven-layout repository with--destination/--to; it updatesmaven-metadata-local.xmlfor the installed artifactjbx skill listandjbx skill get [name]expose version-matched agent guidance bundled with the binary from editableskill-data/filesjbx docs <source|dir>generates Markdown docs from local Java sources without writing cache entriesjbx docs <group:artifact>resolves the latest Maven release metadata before fetchingartifact-version-jbx-docs.mdjbx docs <group:artifact:version> [--json]fetchesartifact-version-jbx-docs.mdor.jsonMaven sidecars and caches remote results under the docs cache namespace; seedocs/jbx-docs-schema.mdfor the JSON shapejbx graph dump <script.java>emits JavaParser's native JSON serialization directly; there is no jbx-specific graph text or custom JSON shapejbx graph import <ast.json>deserializes JavaParser JSON and prints JavaParser-formatted Java source to stdout; pass-o <script.java>/--output <script.java>to write a file- Java 25 compact source files and
import moduledeclarations are parsed directly by JavaParser 3.28.1+ - Java package-aware main-class inference
//FILESresources copied onto the runtime classpath- non-coordinate
//DEPStreated as source dependencies; Maven coordinates may begroup:artifact:version,group:artifact:classifier:version, or justgroup:artifactto resolve the latest release from Maven metadata //PREVIEWcompile/runtime flag handlingjbx resolve <coordinates...>resolve Maven coordinates to dependency listjbx resolve --classpath <coordinates...>resolve to classpathjbx fetch <coordinates...>fetch artifacts and print classpathjbx fetch --deps-only <coordinates...>print coordinates instead of pathsjbx search <text|group:artifact[:version]>queries Maven Central Search;--group,--id/--artifact-id, and--versionadd Solr field filters (g,a,v); default text output is an aligned table sorted by version-count popularity, and--jsonreturns structuredquery,numFound, andartifactsfor agentsjbx jdk listlist discovered/cached JDKsjbx jdk home [version]print the JDK home for a version (default: 25)jbx jdk install <version>download a Temurin JDK from Adoptium- native Maven dependency resolver (no Coursier required)
- reuses existing Maven (
~/.m2/repository), Gradle (~/.gradle/caches), and Coursier (~/.cache/coursier) caches via symlinks - discovers existing JDKs from
JAVA_HOME,PATH, JBang (~/.jbang/jdks), SDKMAN (~/.sdkman/candidates/java), mise (~/.local/share/mise/installs), Gradle (~/.gradle/jdks), and system JVM directories - caches discovered JDKs under
~/.cache/jbx/jdks/<major>via symlinks so future runs do not rescan everything - auto-provisions missing JDKs from Adoptium/Eclipse Temurin with SHA-256 archive verification
Not yet implemented: catalog remove for nested catalogs, multi-file template expansion, template property CLI overrides, export mavenrepo/jlink/project variants, edit integration, and the rest of JBang's lovely edge-case museum.
Example
//JAVA 25+
void
# checks all Java files under the current directory with javac -Xlint:all and Error Prone
# structured javac diagnostics only
# hello world
# runs an executable JAR from Maven coordinates
jbx.json publish descriptor
CENTRAL_TOKEN_USERNAME=... CENTRAL_TOKEN_PASSWORD=...
# or set CENTRAL_PORTAL_TOKEN to base64(username:password)
Use --version when release/tag workflows need to publish a different version than the descriptor. The main field accepts either a source path (src/main/java/dev/telegraphic/demo/HelloTool.java) or a Java FQN (dev.telegraphic.demo.HelloTool). If main has no extension, jbx publish first checks the exact path, then tries .java, .jsh, and .jav next to the descriptor, then scans Java sources under the descriptor directory for a matching package/class declaration; missing main files get an explicit publish main source not found error.
For GitHub-hosted repositories, jbx publish can prefill Maven Central POM url, licenses, developers, and scm metadata from the origin remote plus gh repo view when those fields are omitted. Put the fields in jbx.json when you want explicit release metadata instead of GitHub-derived defaults. Signed Central-ready bundles require a configured GPG key; --skip-signing is only for local inspection. Real Portal publishing requires a generated Maven Central user token supplied via environment variables only: preferably CENTRAL_TOKEN_USERNAME / CENTRAL_TOKEN_PASSWORD, or CENTRAL_PORTAL_TOKEN containing the base64-encoded username:password value expected by the Portal API.
Development