简体   繁体   English

如何将多个类文件转换为一个jar文件?

[英]How to convert multiple class files to one jar file?

I have decompiled a jar file, 我已经反编译了一个jar文件,

在此输入图像描述

and made two classes from it. 从中做了两个班。 After that, I tried to make a new jar file with these two class files, using this code 之后,我尝试使用此代码使用这两个类文件创建一个新的jar文件

jar cvf AB.jar WinRegistry.class StartPageChangeApplet.class

The file created without any errors. 创建的文件没有任何错误。 However, when I look at the source code on Java Decompiler, it says "Internel Error", means that I couldn't make the jar file properly. 但是,当我查看Java Decompiler上的源代码时,它会显示“Internel Error”,这意味着我无法正确制作jar文件。

在此输入图像描述

Where am I doing doing wrong ? 我做错了什么?

Please define "made two classes from it". 请定义“从中制作两个类”。 Which java compiler (eg javac.exe) are you using? 您使用的是哪个java编译器(例如javac.exe)? Did you just copy the source to a .class file without compiling maybe? 您是否只是将源复制到.class文件而不编译?

The java decompiler JAD actually displays source code, not class bytecode. java反编译器JAD实际上显示源代码,而不是类字节码。 Don't get confused by the title of the editor which is saying WinRegistry.class . 不要对编辑器的标题感到困惑,因为WinRegistry.class的编辑器。

So you can't just save that as a .class . 所以你不能只把它保存为.class You need to save it as a .java and then compile it to .class using a java compiler: 您需要将其另存为.java ,然后使用java编译器将其编译为.class

javac WinRegistry.java StartPageChangeApplet.java
jar cf AB.jar WinRegistry.class StartPageChangeApplet.class

From Eclipse, you can do this way.. 从Eclipse,你可以这样做.. 在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM