How to do Eclipse's “export jar” from the command line

后端 未结 1 763
南旧
南旧 2021-01-02 07:49

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

  1. right-click on my project in Eclipse
  2. select \"Export\"
  3. select \"JAR fil
相关标签:
1条回答
  • 2021-01-02 08:08

    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.

    However, a simpler way to build a jar file is to just use 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

    0 讨论(0)
提交回复
热议问题