Last active
November 8, 2022 07:43
-
-
Save minghu6/a72ed2310d2bf064c43b5fcfe75f5cd6 to your computer and use it in GitHub Desktop.
debug jar in command (using IDE like eclipse to connect)
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
#! /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