I have the following Java file(apples.java):
public class apples
{
public static void main(String[] args)
{
System.out.println("Apples here.");
}
}
saved in the source
folder of the MyProject
directory.
I compile apples.java and save the apples.class file into the classes
folder of the MyProject
directory.
I then create manifest.txt with the following content:
Main-Class: apples
I then navigate into the MyProject/classes directory via cmd prompt(Windows XP) and type the following command:
jar -cvmf manifest.txt app1.jar apples.class
I get the following message in the command prompt:
java.io.FileNotFoundException: manifest.txt (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
What is wrong and how do I fix it?
Put the .jar argument first
jar -cvmf app1.jar manifest.txt apples.class
Make sure both "apples.class" and "manifest.jar" are in the current directory.
I would also encourage you to:
1) Use packages (instead of the default package)
2) Capitalize your class names ("Apples.java" instead of "apples")
Here's a nice, short tutorial that might help:
http://www.mkyong.com/java/how-to-add-your-manifest-into-a-jar-file/
It is a common mistake people make. While creating the manifest.txt, make sure that you don't name it "manifest.txt", after you've already selected the file to be a txt. That makes it "manifest.txt.txt". Hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.