Bach.java - Java Shell Builder
Use Java source (in jshell) to build your modular Java project.
___ ___ ___ ___
/\ \ /\ \ /\ \ /\__\
/::\ \ /::\ \ /::\ \ /:/__/_
/::\:\__\/::\:\__\/:/\:\__\/::\/\__\
\:\::/ /\/\::/ /\:\ \/__/\/\::/ /
\::/ / /:/ / \:\__\ /:/ /
\/__/ \/__/ \/__/ \/__/.java
No need to be a maven to be able to use a build tool - forax/pro
📜Fast-forward to install-jdk.sh section.
Execute Bach.java on-the-fly
This section will help you get started with Bach.jsh
used as a remote load-file
of jshell.
0. Install JDK 11 or later
Make sure you have JDK 11 or later installed and configured.
jshell
should be executable from any directory and print its version via:
<path/> jshell --version
jshell 11.0.2
Bach.jsh
into JShell
1. Source Open a command shell and change into the directory containing your modular Java project.
<path/> jshell https://bit.ly/bach-jsh
✨ That's all you need to build a modular Java project. ✨
Note: the shortened
https://bit.ly/bach-jsh
expands to https://raw.githubusercontent.com/sormuras/bach/master/src/bach/Bach.jsh
For immediate results, such as fail-fast on errors, use:
jshell --execution=local https://bit.ly/bach-jsh
For more information what Bach.java is doing at runtime, use:
jshell --execution=local -J-Debug https://bit.ly/bach-jsh
For more details consult the output of jshell --help
.
Directory Layout
🚧
bit.ly links
- https://bit.ly/bach-java 〰️ src/bach/Bach.java
- https://bit.ly/bach-jsh 〰️ src/bach/Bach.jsh
- https://bit.ly/boot-bach 〰️ boot.jsh
install-jdk.sh
install-jdk.sh
main purpose is to install the latest-and-greatest available OpenJDK release from jdk.java.net.
install-jdk.sh
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|11|...|ea JDK feature release number, defaults to "ea"
-o|--os linux-x64|osx-x64 Operating system identifier
-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 real component of the tarball
-c|--cacerts Link system CA certificates (currently only Debian/Ubuntu is supported)
JAVA_HOME
with install-jdk.sh
How to set -
Source
install-jdk.sh
into current shell to install latest OpenJDK and let it updateJAVA_HOME
andPATH
environment variables:source ./install-jdk.sh
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 && ./install-jdk.sh --target $JAVA_HOME && PATH=$JAVA_HOME/bin:$PATH
-
Run
install-jdk.sh
in a sub-shell to install latest OpenJDK and emit the installation path tostdout
:JAVA_HOME=$(./install-jdk.sh --silent --emit-java-home)
JAVA_HOME=$(./install-jdk.sh --emit-java-home | tail --lines 1)
JDK Build Matrix at Travis CI
See sormuras.github.io
's Travic CI configuration for details.