[英]How to do Eclipse's “export jar” from the command line
In my workflow for creating a jar to distribute my code, I currently: 在我创建jar来分发代码的工作流程中,我目前:
This ensures the .class files are up-to-date and creates the jar. 这可以确保.class文件是最新的并创建jar。 I would like to do this same thing from the command line, but most documentation for creating jars seems to be just jarring up files that already exist, without the phase of creating the .class files. 我想从命令行执行相同的操作,但是大多数用于创建jar的文档似乎只是破坏了已经存在的文件,而没有创建.class文件的阶段。 How can I do this from the command line? 我怎么能从命令行执行此操作?
To manually create a jar file, you can use the "jar" utility. 要手动创建jar文件,可以使用“jar”实用程序。 A jar file is basically an archive file (in fact, you can use any zip tool to extract the jar contents). jar文件基本上是一个存档文件(事实上,你可以使用任何zip工具来提取jar内容)。 To create a jar file, you specify the "c" option and all the .class files that you compiled and that you want included. 要创建jar文件,请指定“c”选项以及您编译和要包含的所有.class文件。 The jar command-line mimics the tar command. jar命令行模仿tar命令。 So, for example, to add your class files whose root folder is com, you type: 因此,例如,要添加根文件夹为com的类文件,请键入:
jar cf test.jar com
Optionally, you can add manifest data in the form of a manifest file to specify a default executable and other information. (可选)您可以以清单文件的形式添加清单数据,以指定默认可执行文件和其他信息。
However, a simpler way to build a jar file is to just use ant. 但是,构建jar文件的一种更简单的方法就是使用ant。
Checkout this tutorial from the ant website, which gives an example of a typical ant build file: http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html 从ant网站查看本教程,该网站提供了一个典型的ant构建文件的示例: http : //ant.apache.org/manual/tutorial-HelloWorldWithAnt.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.