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 install-jdk.sh section.
Download a copy of Bach.java to your project's root directory and put the following jshell script in file called build.jsh
.
Launch the build with jshell build.jsh
.
/open Bach.java
new Bach().run("java", "--version")
/exit
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.
Copy and paste the source of bootstrap.jsh to automatically download that latest revisions of Bach.java and Bach.jsh.
//usr/bin/env jshell --show-version "$0" "$@"; exit $?
/*
* Open and load "Bach.java" and "Bach.jsh" into this jshell session.
*/
/open https://github.com/sormuras/bach/raw/master/src/bach/Bach.java
/open https://github.com/sormuras/bach/raw/master/src/bach/Bach.jsh
/*
* Use it!
*/
java("--version")
/exit
install-jdk.sh
main purpose is to install the latest-and-greatest available OpenJDK release from jdk.java.net.
It supports GA releases and builds provided by Oracle as well.
-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)
-
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)