将类文件包含到JAR文件中

时间:2014-07-07 13:34:54

标签: java

任何人都可以告诉我如何使用命令提示符将类文件添加到JAR文件中的特定包中。

示例:Test.jar的包装结构为com.test 现在我想在Test.jar文件的com.test包中添加一个名为Test.class的类文件。

我们非常感谢您的帮助。

2 个答案:

答案 0 :(得分:2)

您可以通过传递'u'参数并提供要添加的JAR和文件来更新JAR文件:

jar uf Test.jar com/test/Test.class

有关此选项的更多信息here

答案 1 :(得分:1)

jar uf jar-file input-file(s)

在此命令中:

The u option indicates that you want to update an existing JAR file.
The f option indicates that the JAR file to update is specified on the command line.
jar-file is the existing JAR file that's to be updated.
input-file(s) is a space-delimited list of one or more files that you want to add to the Jar file.
Any files already in the archive having the same pathname as a file being added will be overwritten.

参考:http://docs.oracle.com/javase/tutorial/deployment/jar/update.html