IDEA插件反编译jar包

安装插件Java Decompiler

安装插件Java Decompiler成功之后重启idea
在这里插入图片描述

找到已安装插件的jar包

在这里插入图片描述

执行反编译

反编译

在已安装插件Java Decompiler的jar包位置下cmd命令执行反编译

java -cp + "插件路径" + org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler -dgs=true + 要反编译的jar包 + 反编译后存储位置

例:

java -cp "C:\Program Files\JetBrains\IntelliJ IDEA 2022.1.3\plugins\java-decompiler\lib\java-decompiler.jar" org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler -dgs=true D:\test\hello.jar D:\test\hello

解压jar包

反编译之后会在指定位置生成反编译之后的jar包,解压之后使用idea查看即可。

排错

执行可能报错:

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(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)

原因一:
jre和jdk版本不一致
执行命令查看版本是否一致,若是版本一致应该是第二种原因,若不一致,重新配置jdk环境变量即可。

javac -version
java -version

原因二:
class文件版本跟jdk版本对应关系如下,
你需要安装对应的jdk版本再执行反编译命令。

49 = Java 5
50 = Java 6
51 = Java 7
52 = Java 8
53 = Java 9
54 = Java 10
55 = Java 11
56 = Java 12
57 = Java 13
58 = Java 14
59 = Java 15
60 = Java 16

猜你喜欢

转载自blog.csdn.net/weixin_42949219/article/details/132496962