Decompiling A Jar File With Jd-Cli: Processes And Output Options

decompile
JAR file
jd-cli
command line tool
serial processing
skip resources
output options
This text explains the process of decompiling a single JAR file using jd-cli, a command line tool. It covers steps such as serial processing and skipping resources, and provides output options including console, directory, structured directory, or ZIP file with customizable paths.
Published

May 20, 2024


Java jar file decompiler

To decompile a single jar file we need more than just jd-core, which is a commandline tool to decompile a single class file at a time.

Use jd-cli which is downloadable at here.

Commandline usage:

# without docker
java -jar jd-cli.jar file-to-decompile.jar -ods decompiled-src
# with docker
docker run -it --rm -v `pwd`:/mnt --user $(id -u):$(id -g) \
kwart/jd-cli /mnt/file-to-decompile.jar -ods /mnt/decompiled-src

Full syntax:

Usage: java -jar jd-cli.jar [options] [Files to decompile]
Options:
--displayLineNumbers, -n
displays line numbers in decompiled classes
Default: false
--escapeUnicodeCharacters, -eu
escape unicode characters in decompiled classes
Default: false
--help, -h
shows this help
Default: false
--logLevel, -g
takes [level] as parameter and sets it as the CLI log level. Possible
values are: ALL, TRACE, DEBUG, INFO, WARN, ERROR, OFF
Default: INFO
--outputConsole, -oc
enables output to system output stream
Default: false
--outputDir, -od
takes a [directoryPath] as a parameter and configures a flat DIR output
for this path
--outputDirStructured, -ods
takes a [directoryPath] as a parameter and configures a structured DIR
output for this path
--outputZipFile, -oz
takes a [zipFilePath] as a parameter and configures ZIP output for this
path
--pattern, -p
RegExp pattern which the to-be-decompiled file has to match. Not matching
entries are skipped.
--serialProcessing, -sp
don't use parallel processing
Default: false
--skipResources, -sr
skips processing resources
Default: false
--version, -v
shows the version
Default: false