Skip to content

Instantly share code, notes, and snippets.

@minghu6
Last active November 8, 2022 07:43
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 minghu6/a72ed2310d2bf064c43b5fcfe75f5cd6 to your computer and use it in GitHub Desktop.
Save minghu6/a72ed2310d2bf064c43b5fcfe75f5cd6 to your computer and use it in GitHub Desktop.
debug jar in command (using IDE like eclipse to connect)
#! /bin/bash
DEFAULT_PORT=9009;
port=$DEFAULT_PORT;
pring_usage(){
echo "Usage: jardb [-p=port default: $DEFAULT_PORT] target-jar";
}
while getopts ":p:h" optname
do
case "$optname" in
"p")
port=$OPTARG;
;;
"h")
pring_usage;
exit 0;
;;
*)
# Should not occur
echo "Unknown error while processing options";
exit 1;
;;
esac
done
target_jar=${@: -1};
if echo "$target_jar" | grep -e ".*jar"
then
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=$port -jar "$target_jar";
else
echo "Miss target jar file";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment