繁体   English   中英

尝试创建jar文件时找不到文件异常

[英]file not found exception when trying to create jar file

我有以下Java文件(apples.java):

public class apples
{
   public static void main(String[] args)
    {
       System.out.println("Apples here.");
    }
}

保存在MyProject目录的source文件夹中。

我编译apples.java并将apples.class文件保存到MyProject目录的classes文件夹中。

然后,我创建带有以下内容的manifest.txt:

Main-Class: apples

然后,我通过cmd提示符(Windows XP)导航到MyProject / classes目录,并键入以下命令:

jar -cvmf manifest.txt app1.jar apples.class

我在命令提示符下收到以下消息:

java.io.FileNotFoundException: manifest.txt (The system cannot find the file specified)

           at java.io.FileInputStream.open(Native Method)

有什么问题,我该如何解决?

首先放.jar参数

jar -cvmf app1.jar manifest.txt apples.class

确保“ apples.class”和“ manifest.jar”都在当前目录中。

我也鼓励您:

1)使用软件包(而不是默认软件包)

2)大写您的类名(“ Apples.java”而不是“ apples”)

这是一个不错的简短教程,可能会有所帮助:

http://www.mkyong.com/java/how-to-add-your-manifest-into-a-jar-file/

这是人们常犯的错误。 在创建manifest.txt时,请确保已将文件选择为txt之后,不要将其命名为“ manifest.txt”。 这就是“ manifest.txt.txt”。 希望能帮助到你。

暂无
暂无

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

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