简体   繁体   English

错误:没有这样的文件或目录试图从终端创建 jar 文件

[英]ERROR: no such file or directory trying to create jar file from terminal

I have performed the following steps:我执行了以下步骤:

  • A single java file called ComputeArray.java, with no specified package一个名为 ComputeArray.java 的 java 文件,没有指定的包
  • Navigated into the folder containing the program导航到包含程序的文件夹
  • Created the class file (and it runs)创建类文件(并运行)

The command I am having trouble with is as follows:我遇到问题的命令如下:

  • jar cvf computearray.jar ComputeArray.class jar cvf 计算阵列.jar ComputeArray.class

And I have tried using a manifest with cvmf and also tried adding ComputeArray.java at the end.我已经尝试使用带有 cvmf 的清单,并尝试在最后添加 ComputeArray.java。 I always end up with the same error "no such file or directory我总是以同样的错误告终“没有这样的文件或目录

You also have to specify the manifest file while creating jar file, something like:您还必须在创建 jar 文件时指定清单文件,例如:

$ jar cmf Hello.mf Hello.jar Hello.class Hello.java

Here is great documentation to Distributing your Application as an executable JAR file: https://introcs.cs.princeton.edu/java/85application/jar/jar.html以下是将您的应用程序作为可执行 JAR 文件分发的很棒的文档: https : //introcs.cs.princeton.edu/java/85application/jar/jar.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM