Created
March 7, 2022 07:10
-
-
Save trustin/5946e8f5c4221e944d8fa17f9f726273 to your computer and use it in GitHub Desktop.
SJK (Swiss Java Knife) launcher script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -Eeuo pipefail | |
if [[ -z "${JAVA_HOME:-}" ]]; then | |
JAVA='java' | |
else | |
JAVA="$JAVA_HOME/bin/java" | |
fi | |
SJK_VERSION='0.20' | |
SJK_PATH="$HOME/.local/opt/sjk/sjk-plus-$SJK_VERSION.jar" | |
SJK_URL="https://repo.maven.apache.org/maven2/org/gridkit/jvmtool/sjk-plus/$SJK_VERSION/sjk-plus-$SJK_VERSION.jar" | |
SJK_SHA256='c10aeb794137aebc1f38de0a627aaed270fc545026de216d36b8befb6c31d860' | |
# Download sjk-plus.jar if not downloaded yet. | |
if [[ ! -a "$SJK_PATH" ]]; then | |
echo "Downloading SJK .." | |
cleanup() { | |
rm -f "$SJK_PATH.tmp" | |
} | |
trap cleanup ERR | |
trap cleanup EXIT | |
trap cleanup SIGINT | |
mkdir -p "$(dirname "$SJK_PATH")" | |
cleanup | |
curl -L -o "$SJK_PATH.tmp" "$SJK_URL" | |
if [[ ! "$(sha256sum "$SJK_PATH.tmp")" =~ (^$SJK_SHA256) ]]; then | |
echo 'Downloaded JAR has incorrect SHA256 checksum' | |
exit 1 | |
fi | |
mv "$SJK_PATH.tmp" "$SJK_PATH" | |
echo | |
fi | |
if [[ "$#" -eq 0 ]]; then | |
ARGS=('--commands') | |
else | |
ARGS=("$@") | |
fi | |
exec "$JAVA" --add-opens java.base/jdk.internal.perf=ALL-UNNAMED --add-opens jdk.attach/sun.tools.attach=ALL-UNNAMED -jar "$SJK_PATH" "${ARGS[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script is a convenient launcher script for SJK (Swiss Java Knife). It downloads and launches the
sjk-plus.jar
from Maven Central into~/.local/opt/sjk
.