1

Continuing from my previous UseOfManifestFile thread, i advanced to use my own MANIFEST.MF file rather then using the default one created from the jar tool. I am attaching the snapshot here. Sample Directory Structure And Command. It shows my directory structure as well as the command i am using. It's not using my MANIFEST.MF file. I don't know why and default is getting created. What mistake i am committing? I also swapped the MANIFEST.MF file name and jar name and now it gives the following error.

Swapped Command

Can anyone help me in this.

Directory Structure

d:->corejava | chapter10 | tictactoe.jar | tictactoe | HelloWorld.class , audio(folder), images(folder)

My point is, i was able to add the contents of Manifest.txt into the MANIFEST.MF file. Now when i try to run the jar from chapter directory using the following command :-

java jar tictactoe.jar

It gives the following error to me

Error: Could not find or load main class jar  

Can someone help me in this.

Community
  • 1
  • 1
benz
  • 4,561
  • 7
  • 37
  • 68
  • As I understand your question is why is there a default MANIFEST entries along with your custom MANIFEST? Correct me if I am wrong. If my understanding is correct, jar cfm creates a jar file by merging the text file you pass with the default MANIFEST file f indicates the output to go to a file than standard output. See the below link which gives you in detail about the jar command and usage. http://docs.oracle.com/javase/tutorial/deployment/jar/modman.html – Abhijith Nagarajan Nov 19 '13 at 11:55
  • No Abhijith, actually i wanted to mark the entry for Main class in my jar. So i saw how i can add additional instructions to the mainfest file. i gave command as jar cfm jarname Manifest.txt tictactoue. Issue is, its not merging my addition with main Manifest file. – benz Nov 19 '13 at 12:01
  • Can you add the contents of Manifest.txt? – Abhijith Nagarajan Nov 19 '13 at 12:07
  • “shows my directory structure” **what** shows your directory structure? I don’t see any directory structure nor any other indication that it didn’t work. – Holger Nov 19 '13 at 13:10
  • i have tried to add the directory structure and now it gives the error when i try to run the jar, it can't find or load main class. – benz Nov 19 '13 at 18:18

1 Answers1

1

I figured out the issue. Here are the points which i concluded and successfully executed the program.

  1. Make sure your Manifest.txt file ends with a carriage return as per the instructions Setting An Application Entry Point. Otherwise it won't be parsed correctly.
  2. If it's in a package make sure, its properly compiled.
  3. The command to run a jar is given below

    java -jar JarName.jar

I followed the above steps and was able to execute my program.

Thanks everyone.

benz
  • 4,561
  • 7
  • 37
  • 68