当前位置:网站首页>jar文件 反编译(IDEA环境)
jar文件 反编译(IDEA环境)
2022-07-26 18:26:00 【xsqsharp】
说明
想要对一些 jar 文件进行反编译,由于现在 IDEA 使用的人比较多,比较方便的方法是,可以使用 IDEA 中的插件进行反编译。
IDEA 插件
可以使用 IDEA 中的 "Java Bytecode Decompiler",该插件一般都内置了,可以直接使用。找到该插件的位置。
Java Bytecode Decompiler 位置:D:\DevTools\JetBrains\IntelliJ IDEA 2021.1\plugins\java-decompiler\lib\java-decompiler.jar
要反编译的jar包位置:F:\javadecom\helloworld.jar

打开控制台,进入到要反编译的 jar 包的目录中,反编译命令:
java -cp "D:/DevTools/JetBrains/IntelliJ IDEA 2021.1/plugins/java-decompiler/lib/java-decompiler.jar" org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler -dgs=true F:/javadecom/helloworld.jar data
说明
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler:是插件的启动类。
data:是在要反编译的 jar 包路径下的一个文件夹,需要提前创建好,反编译后的结果会放在该文件夹中。
执行命令,此时出现一个错误,如下图所示:

错误详细信息:
F:\javadecom>java -cp "D:/DevTools/JetBrains/IntelliJ IDEA 2021.1/plugins/java-decompiler/lib/java-decompiler.jar" org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler -dgs=true F:/javadecom/helloworld.jar data
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/jetbrains/java/decompiler/main/decompiler/ConsoleDecompiler has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
意思是 JDK11 编译的代码,无法使用 JDK8 反编译。
此时需要下载一个 JDK11,下载好后,可以指定使用 JDK11 进行反编译。
- JDK11 位置:D:\DevTools\Java\jdk-11.0.12\bin\java.exe
指定使用 JDK11 反编译命令:
D:/DevTools/Java/jdk-11.0.12/bin/java.exe -cp "D:/DevTools/JetBrains/IntelliJ IDEA 2021.1/plugins/java-decompiler/lib/java-decompiler.jar" org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler -dgs=true F:/javadecom/helloworld.jar data

反编译完成后,会在 data 目录中生成 jar 反编译的文件。

将该文件解压出来,就是反编译的代码。
边栏推荐
猜你喜欢
随机推荐
密码一致,总显示如下图
【C语言实现】----动态/文件/静态通讯录
MapReduce (II)
Machine learning notes - building a recommendation system (6) six automatic encoders for collaborative filtering
Aof & RDB of J2 redis
[C language implementation] - dynamic / file / static address book
首席信息官引导业务变革的指南
2022搭建企业级数据治理体系
How to solve the problem that win11 has been switched on after upgrading
Redis6
PADS画2.54mm排针
测试面试题集-UI自动化测试
周末看点回顾|数字人民币产业联盟成立;中国移动宣布:和飞信将停止服务…
ReentrantLock学习之---释放锁过程
[skim] two point answer solution
Wechat applet plug-in -- wxml to canvas (generate pictures)
IJCAI2022开会了! Brescia等《证据推理和学习》教程,阐述其最新进展,附96页Slides
Test interview question set UI automated test
如果密钥忘记,多个设备分别不同的密钥,云端是如何同步
Customer cases | focus on process experience to help bank enterprise app iteration










