怎么办Eclipse的"出口罐子"在命令行 [英] How to do Eclipse's "export jar" from the command line

查看:126
本文介绍了怎么办Eclipse的"出口罐子"在命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的工作流创建一个罐子来分发我的code,我现在:

In my workflow for creating a jar to distribute my code, I currently:

  1. 在我的Eclipse项目
  2. 右键点击
  3. 选择导出
  4. 选择JAR文件
  5. 取消类似的.classpath顶层文件的.project
  6. 检查只是导出生成的类文件
  7. 单击完成
  1. right-click on my project in Eclipse
  2. select "Export"
  3. select "JAR file"
  4. uncheck the top-level files like .classpath, .project
  5. check only "export generated class files"
  6. click "finish"

这保证了.class文件是最新的最新,并创建罐子。我想这样做同样的事情,在命令行中,但大多数文档创建罐子似乎只是不和谐了已经存在的文件,而无需创建.class文件的阶段。我怎样才能做到这一点的命令行?

This ensures the .class files are up-to-date and creates the 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. How can I do this from the command line?

推荐答案

要手动创建一个jar文件,可以使用jar实用工具。 一个JAR文件基本上是一个存档文件(实际上,你可以使用任何ZIP工具来解压JAR的内容)。要创建一个jar文件,您指定的C选项,所有你编译并要包含.class文件。 jar命令行模仿tar命令。因此,例如,添加类文件的根目录为com,输入:

To manually create a jar file, you can use the "jar" utility. A jar file is basically an archive file (in fact, you can use any zip tool to extract the jar contents). To create a jar file, you specify the "c" option and all the .class files that you compiled and that you want included. The jar command-line mimics the tar command. So, for example, to add your class files whose root folder is com, you type:

  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.

然而,一个更简单的方法来建立一个jar文件是只使用一只蚂蚁。

However, a simpler way to build a jar file is to just use ant.

结帐本教程从蚂蚁网站,该网站提供了一个典型的Ant构建文件的示例: http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html

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

这篇关于怎么办Eclipse的"出口罐子"在命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆