Skip to content

Instantly share code, notes, and snippets.

@xranby
Created October 17, 2021 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xranby/e7549d016fc6365e021ce99b5bfb2911 to your computer and use it in GitHub Desktop.
Save xranby/e7549d016fc6365e021ce99b5bfb2911 to your computer and use it in GitHub Desktop.
unpacked jar java example
#!/bin/sh
# assume you have a java application named update/*.jar that is using jars in update/lib/.jar
# this script will unpack all jars into the run folder
# then start your application inside the run folder with very simple classpath options
sdir=`dirname $(readlink -f $0)`
rootdir=`dirname $sdir`
echo rootdir $rootdir
# Remove the old run dir, recreate it
rm -rf $rootdir/run > /dev/null
mkdir -p $rootdir/run
cd $rootdir/run
# Unpack all jars into run
for z in $rootdir/update/*.jar; do echo $z ; unzip -oq $z; done
for z in $rootdir/update/lib/*.jar; do
# do not override update/*.jar with update/lib/*jar content
if [ ! -e $rootdir/update/`basename $z` ] ; then
echo $z ; unzip -oq $z
else
echo `basename $z` " duplicate in update and update/lib"
fi
done
# Run your main class
java -Djava.library.path=. -classpath . mainClass
cd $rootdir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment