Last active
June 13, 2023 18:38
-
-
Save averycowan/60b050117165d7507931b4d00dfdeeab to your computer and use it in GitHub Desktop.
make_jar_executable
This file contains 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 | |
# Usage: make_jar_executable <jarfile> | |
# This script will make a unix executable copy of any jar file | |
# A new file will be created with the same path as <jarfile> without the extension | |
# That file will be executable and is fully self-contained. | |
# Get the file path | |
jarfile=$1 | |
# Get the path with no extension | |
outpath=${jarfile%.*} | |
# Create the launcher | |
echo '#!/bin/sh' >> $outpath | |
echo >> $outpath | |
echo 'exec java -jar "$0" "$@"' >> $outpath | |
# Copy the contents of the jar over | |
cat $jarfile >> $outpath | |
# Make it executable | |
chmod +x $outpath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment