Java Shell Builder - Use jshell to build your modular project
Switch branches/tags
Clone or download

bach - Java Shell Builder

jdk11 travis experimental

Use Java source in jshell to build your modular project.

No need to be a maven to be able to use a build tool - forax/pro

Fast-forward to section.

simple usage

Download a copy of to your project's root directory and put the following jshell script in file called build.jsh. Launch the build with jshell build.jsh.


new Bach().run("java", "--version")


make it executable

Want to call just ./build to launch the build?

Add the following pseudo-shebang as the first line to build.jsh:

//usr/bin/env jshell --show-version "$0" "$@"; exit $?

Don't forget to mark your build script executable, i.e. chmod u+x build.jsh. See bootstrap on-the-fly section below for an example.

bootstrap on-the-fly

Copy and paste the source of bootstrap.jsh to automatically download that latest revisions of and Bach.jsh.

//usr/bin/env jshell --show-version "$0" "$@"; exit $?

 * Open and load "" and "Bach.jsh" into this jshell session.

 * Use it!

/exit main purpose is to install the latest-and-greatest available OpenJDK release from It supports GA releases and builds provided by Oracle as well.

Options of

-h|--help                 Displays this help
-d|--dry-run              Activates dry-run mode
-s|--silent               Displays no output
-e|--emit-java-home       Print value of "JAVA_HOME" to stdout (ignores silent mode)
-v|--verbose              Displays verbose output

-f|--feature 9|10|...|ea  JDK feature release number, defaults to "ea"
-l|--license GPL|BCL      License defaults to "GPL"
-o|--os linux-x64|osx-x64 Operating system identifier (works best with GPL license)
-u|--url "https://..."    Use custom JDK archive (provided as .tar.gz file)
-w|--workspace PATH       Working directory defaults to user's ${HOME}
-t|--target PATH          Target directory, defaults to first component of the tarball
-c|--cacerts              Link system CA certificates (currently only Debian/Ubuntu is supported)

How to set JAVA_HOME with

  • Source into current shell to install latest OpenJDK and let it update JAVA_HOME and PATH environment variables:

    • source ./ Caveat: if an error happens during script execution the calling shell will terminate
  • Provide target directory path to use as JAVA_HOME:

    • JAVA_HOME=~/jdk && ./ --target $JAVA_HOME && PATH=$JAVA_HOME/bin:$PATH
  • Run in a sub-shell to install latest OpenJDK and emit the installation path to stdout:

    • JAVA_HOME=$(./ --silent --emit-java-home)
    • JAVA_HOME=$(./ --emit-java-home | tail --lines 1)

be free - have fun