java反编译class

简介: java反编译class

让我们不要用过去的哀悉拖累我们的记忆。——莎士比亚

反编译classjava文件,我们可以用到jad

下载

使用方式:

首先解压jar

jad所在目录下执行

jad.exe -r -ff -d D:\mc\source\FortuneTelling -s java D:\mc\source\original-FortuneTelling-1.0-SNAPSHOT\**\*.class

ps:

jad.exe -r -ff -d [反编译后代码存放路径] -s java [需要反编译包含class的目录]\**\*.class

帮助

This is README file for Jad - the fast Java Decompiler.
Jad home page: http://www.kpdus.com/jad.html
Copyright 2001 Pavel Kouznetsov (jad@kpdus.com).
0. Please read the disclaimer on the Jad home page.
1. Installation.
Unzip jad.zip file into any appropriate directory on your hard drive.
This will create two files:
    - an executable file named 'jad.exe' (Windows *)
      or 'jad' (*n*x)
    - this README file
No other setup is required.
2. How to use Jad
To decompile a single JAVA class file 'example1.class' 
type the following:
     jad example1.class
This command creates file 'example1.jad' in the current directory.
If such file already exists Jad asks whether you want to overwrite it or not.
Option -o permits overwriting without a confirmation.
You can omit .class extension and/or use wildcards in the names of
input files.
Option -s <ext> allows to change output file extension:
     jad -sjava example1.class
This command creates file 'example1.java'. Be careful when using
options -o and -sjava together, because Jad can accidentally overwrite
your own source files.
Jad uses JAVA class name as an output file name. For example, if class
file 'example1.class' contains JAVA class 'test1' then Jad will create
file 'test1.jad' rather than 'example1.jad'. If you want to specify
your own output file name use the output redirection:
   jad -p example1.class > myexm1.java
Option -d allows you to specify another directory for output files,
which are created, by default, in the current directory. For example:
   jad -o -dtest -sjava *.class
   (or jad -o -d test -s java *.class, which has the same effect)
This command decompiles all .class files in the current directory 
and places all output files with extension .java into directory 'test'.
If you want to decompile the whole tree of JAVA classes,
use the following command:
   jad -o -r -sjava -dsrc tree/**/*.class
This command decompiles all .class files located in all 
subdirectories of 'tree' and creates output files in subdirectories
of 'src' according to package names of classes. For example, if file 
'tree/a/b/c.class' contains class 'c' from package 'a.b', then 
output file will have a name 'src/a/b/c.java'.
Note the use of the "two stars" wildcard ('**') in the previous
command. It is handled by Jad rather than the command shell, so on
UNIX the last argument should be single-quoted:
   jad -o -r -sjava -dsrc 'tree/**/*.class'
In a case you want to check the accuracy of the decompilation or just
curious, there is an option -a which tells Jad to annotate the output
with JAVA Virtual Machine bytecodes.
Jad supports the inner and anonymous classes. 
When Jad expands wildcards in the input file names, 
it automatically skips matching inner classes. 
On UNIX Jad skips inner classes if there is more than 
one class specified in the command line.
Jad looks for inner classes in the directory of their top-level
container class.
3. List of the command-line options.
Jad accepts the following options:
   -a       - annotate the output with JVM bytecodes (default: off)
   -af      - same as -a, but output fully qualified names when annotating
   -clear   - clear all prefixes, including the default ones (can be abbreviated as -cl)
   -b       - output redundant braces (e.g., if(a) { b(); }, default: off)
   -d <dir> - directory for output files (will be created when necessary)
   -dead    - try to decompile dead parts of code (if any) (default: off)
   -disass  - disassemble method bytecodes (no JAVA source generated)
   -f       - output fully qualified names for classes/fields/methods (default: off)
   -ff      - output class fields before methods (default: after methods)
   -i       - output default initializers for all non-final fields
   -l<num>  - split strings into pieces of maximum <num> chars (default: off)
   -lnc     - annotate the output with line numbers (default: off)
   -lradix<num> - display long integers using the specified radix (8, 10 or 16)
   -nl      - split strings on newline character (default: off)
   -nocast  - don't generate auxiliary casts
   -nocode  - don't generate the source code for methods
   -noconv  - don't convert Java identifiers (default: convert)
   -noctor  - suppress the empty constructors
   -nodos   - do not check for class files written in DOS mode (CR before NL, default: check)
   -nofd    - don't disambiguate fields with the same names by adding signatures to their names (default: do)
   -noinner - turn off the support of inner classes (default: on)
   -nolvt   - ignore Local Variable Table information
   -nonlb   - don't output a newline before opening brace (default: do)
   -o       - overwrite output files without confirmation (default: off)
   -p       - send decompiled code to STDOUT (e.g., for piping)
   -pi<num> - pack imports into one line after <num> imports (default: 3)
   -pv<num> - pack fields with identical types into one line (default: off)
   -pa <pfx>- prefix for all packages in generated source files
   -pc <pfx>- prefix for classes with numerical names (default: _cls)
   -pf <pfx>- prefix for fields with numerical names (default: _fld)
   -pe <pfx>- prefix for unused exception names (default: _ex)
   -pl <pfx>- prefix for locals with numerical names (default: _lcl)
   -pm <pfx>- prefix for methods with numerical names (default: _mth)
   -pp <pfx>- prefix for method parms with numerical names (default: _prm)
   -r       - restore package directory structrure
   -radix<num> - display integers using the specified radix (8, 10 or 16)
   -s <ext> - output file extension (by default '.jad')
   -safe    - generate additional casts to disambiguate methods/fields (default: off)
   -space   - output space between keyword (if/for/while/etc) and expression (default: off)
   -stat    - display the total number of processed classes/methods/fields
   -t       - use tabs instead of spaces for indentation
   -t<num>  - use <num> spaces for indentation (default: 4)
   -v       - display method names being decompiled
   -8       - convert UNICODE strings into 8-bit strings
              using the current ANSI code page (Win32 only)
   -&       - redirect STDERR to STDOUT (Win32 only)
All single-word options have three formats:
  -o    - 'reverses' value of an option
  -o+   - set value to 'true' or 'on'
  -o-   - set value to 'false' or 'off'
You can specify the options you want to be set by default in the environment variable
JAD_OPTIONS. For example:
JAD_OPTIONS=-ff+ -nonlb+ -t+ -space+
相关文章
|
26天前
|
Java 编译器 Maven
Java“class file contains wrong class”解决
当Java程序运行时出现“class file contains wrong class”错误,通常是因为类文件与预期的类名不匹配。解决方法包括:1. 确保类名和文件名一致;2. 清理并重新编译项目;3. 检查包声明是否正确。
|
2月前
|
Java Maven 数据安全/隐私保护
如何实现Java打包程序的加密代码混淆,避免被反编译?
【10月更文挑战第15天】如何实现Java打包程序的加密代码混淆,避免被反编译?
58 2
|
2月前
|
Java 程序员 编译器
在Java编程中,保留字(如class、int、for等)是具有特定语法意义的预定义词汇,被语言本身占用,不能用作变量名、方法名或类名。
在Java编程中,保留字(如class、int、for等)是具有特定语法意义的预定义词汇,被语言本身占用,不能用作变量名、方法名或类名。本文通过示例详细解析了保留字的定义、作用及与自定义标识符的区别,帮助开发者避免因误用保留字而导致的编译错误,确保代码的正确性和可读性。
50 3
|
3月前
|
Java
java基础(4)public class 和class的区别及注意事项
本文讲解了Java中`public class`与`class`的区别和注意事项。一个Java源文件中只能有一个`public class`,并且`public class`的类名必须与文件名相同。此外,可以有多个非`public`类。每个类都可以包含一个`main`方法,作为程序的入口点。文章还强调了编译Java文件生成`.class`文件的过程,以及如何使用`java`命令运行编译后的类。
45 3
java基础(4)public class 和class的区别及注意事项
|
2月前
|
Java
让星星⭐月亮告诉你,Java synchronized(*.class) synchronized 方法 synchronized(this)分析
本文通过Java代码示例,介绍了`synchronized`关键字在类和实例方法上的使用。总结了三种情况:1) 类级别的锁,多个实例对象在同一时刻只能有一个获取锁;2) 实例方法级别的锁,多个实例对象可以同时执行;3) 同一实例对象的多个线程,同一时刻只能有一个线程执行同步方法。
19 1
|
2月前
|
小程序 Oracle Java
JVM知识体系学习一:JVM了解基础、java编译后class文件的类结构详解,class分析工具 javap 和 jclasslib 的使用
这篇文章是关于JVM基础知识的介绍,包括JVM的跨平台和跨语言特性、Class文件格式的详细解析,以及如何使用javap和jclasslib工具来分析Class文件。
49 0
JVM知识体系学习一:JVM了解基础、java编译后class文件的类结构详解,class分析工具 javap 和 jclasslib 的使用
|
3月前
|
Java
java的class类
java的class类
37 5
|
4月前
|
Java 测试技术 Docker
记录一次很坑的报错:java.lang.Exception: The class is not public.
这篇文章记录了作者在Docker中运行服务进行单元测试时遇到的一系列问题,包括Spring Boot与Spring Cloud版本不一致、Bean注入问题、测试单元引入问题以及公共类和方法的可见性问题,并提供了解决问题的方法和成功测试通过的代码示例。
记录一次很坑的报错:java.lang.Exception: The class is not public.
|
4月前
|
Java
JAVA中public class和class的区别
JAVA中public class和class的区别
49 7
|
4月前
|
Oracle Java 关系型数据库
简单记录在Linux上安装JDK环境的步骤,以及解决运行Java程序时出现Error Could not find or load main class XXX问题
本文记录了在Linux系统上安装JDK环境的步骤,并提供了解决运行Java程序时出现的"Error Could not find or load main class XXX"问题的方案,主要是通过重新配置和刷新JDK环境变量来解决。
145 0
下一篇
无影云桌面