java jar - cvf 命令没有运行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14639869/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 16:56:09  来源:igfitidea点击:

jar - cvf command is not running?

javahadoopjar

提问by Ananda

I created a wordcount example in MapReduce and trying to make the jar file using following command:

我在 MapReduce 中创建了一个 wordcount 示例,并尝试使用以下命令制作 jar 文件:

hduseros@MT2012018:/usr/local/hadoop$ jar -cvf playground/wordcount.jar -C playground/classes

But Its not at all running and giving me following result:

但它根本没有运行并给我以下结果:

hduseros@MT2012018:/usr/local/hadoop$ jar -cvf playground/wordcount.jar -C playground/classes
Usage: jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point] [-C dir] files ...
Options:
    -c  create new archive
    -t  list table of contents for archive
    -x  extract named (or all) files from archive
    -u  update existing archive
    -v  generate verbose output on standard output
    -f  specify archive file name
    -m  include manifest information from specified manifest file
    -e  specify application entry point for stand-alone application 
        bundled into an executable jar file
    -0  store only; use no ZIP compression
    -M  do not create a manifest file for the entries
    -i  generate index information for the specified jar files
    -C  change to the specified directory and include the following file
If any file is a directory then it is processed recursively.
The manifest file name, the archive file name and the entry point name are
specified in the same order as the 'm', 'f' and 'e' flags.

Example 1: to archive two class files into an archive called classes.jar: 
       jar cvf classes.jar Foo.class Bar.class 
Example 2: use an existing manifest file 'mymanifest' and archive all the
           files in the foo/ directory into 'classes.jar': 
       jar cvfm classes.jar mymanifest -C foo/ .

Please correct where I am wrong. I have set the class path. I can run the examples already present but not able to make jar file.

请纠正我错的地方。我已经设置了类路径。我可以运行已经存在的示例,但无法制作 jar 文件。

回答by aa8y

That is probably because you haven't given it the location where it needs to pick the files from. Try this:

这可能是因为您没有为其提供需要从中挑选文件的位置。试试这个:

jar -cvf playground/wordcount.jar -C playground/classes .

And include the last dot (.)

并包括最后一个点 (.)

回答by Shaun

Try eliminating the dash: jar cvf, not jar -cvf

尝试消除破折号:jar cvf,而不是jar -cvf

回答by Shaun

Try to perform the following command:

尝试执行以下命令:

jar cvf playground/wordcount.jar playground/classes/*.class

See also: Building a JAR File of Interface Classes

另请参阅:构建接口类的 JAR 文件