如何打开 JAR 以在 Netbeans 中进行编辑

How can I open a JAR for editing in Netbeans

我制作了一个 JAR 文件。运行良好。我一直在修改源代码,但我忘记了进行了哪些更改。现在那是行不通的。我能以某种方式从 Jar 中拉出 .java 吗?

一个 JAR 只包含 .class 个文件,这些文件是从 .java 个源文件编译而来的。不幸的是,您无法编辑 .class 文件并期望从中得到任何有用的东西。

不过这可能有用:JD GUI,一个 JAR 反编译器。

jar 文件类似于 zip 文件,您可以提取其中的内容。从oracle网站命令行解压(也可以用7zip之类的程序):

用于提取 JAR 文件内容的基本命令是:

jar xf  jar-file [archived-file(s)]

让我们看看这个命令中的选项和参数:

The x option indicates that you want to extract files from the JAR archive.
The f options indicates that the JAR file from which files are to be extracted is specified on the command line, rather than through stdin.
The jar-file argument is the filename (or path and filename) of the JAR file from which to extract files.
archived-file(s) is an optional argument consisting of a space-separated list of the files to be extracted from the archive. If this argument is not present, the Jar tool will extract all the files in the archive.

注意:jar 文件可以包含 任何 类型的文件,而不仅仅是 .class 文件。

解压 jar 只会给你 .class 个文件。您仍然可以尝试 java decompilers,它可以从 .class 文件

生成源代码

虽然不能 100% 保证结果