Name: dcompile
Description: Compile a single jar file to java classes.
Usage: dcompile <FILE-NANE>
Example: dcompile ./*.jar
Notes: Please make sure jad is in the system path.
Source Code:
#!/bin/bash
if [ -z ${1} ]
then
echo "Missing paramer - jar file path"
exit
fi
JAR_FILE=${1}
JAR_FILE_NAME=$(basename $JAR_FILE)
JAR_FILE_NAME=${JAR_FILE_NAME%%.jar}
DEST_DIR=${2}
if [ -z $DEST_DIR ]
then
DEST_DIR=$JAR_FILE_NAME
fi
mkdir -p $DEST_DIR
echo "JAR_FILE: ${JAR_FILE}"
echo "JAR_FILE_NAME: ${JAR_FILE_NAME}"
echo "DEST_DIR: ${DEST_DIR}"
rm -r /tmp/$JAR_FILE_NAME &> /dev/null
unzip $JAR_FILE -d /tmp/$JAR_FILE_NAME
find /tmp/$JAR_FILE_NAME -name "*.class" -exec jad -r -s java -d $DEST_DIR {} \;
if [ -z ${1} ]
then
echo "Missing paramer - jar file path"
exit
fi
JAR_FILE=${1}
JAR_FILE_NAME=$(basename $JAR_FILE)
JAR_FILE_NAME=${JAR_FILE_NAME%%.jar}
DEST_DIR=${2}
if [ -z $DEST_DIR ]
then
DEST_DIR=$JAR_FILE_NAME
fi
mkdir -p $DEST_DIR
echo "JAR_FILE: ${JAR_FILE}"
echo "JAR_FILE_NAME: ${JAR_FILE_NAME}"
echo "DEST_DIR: ${DEST_DIR}"
rm -r /tmp/$JAR_FILE_NAME &> /dev/null
unzip $JAR_FILE -d /tmp/$JAR_FILE_NAME
find /tmp/$JAR_FILE_NAME -name "*.class" -exec jad -r -s java -d $DEST_DIR {} \;
转载于:https://blog.51cto.com/robertleepeak/196996