This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Trouble making JAR file that works. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Trouble making JAR file that works. " Watch "Trouble making JAR file that works. " New topic
Author

Trouble making JAR file that works.

Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
Hello i've been trying to make a jar file and something seems to be going wrong.

This is an article with the instructions i have been following Creating an Executable jar file
The error i'm getting when i try to run the jar file is "Could not find the main class: TurtleTest3 . Program will exit."

I have 3 classes in my program the one with the main method is called "TurtleTest3" and the other two are called "Turtle3" and "Instructions".

These are the exact steps i have taken. I am using command prompt.


echo Main-Class: TurtleTest3 >manifest.txt

(then i push enter)

jar cvfm TurtleGame.jar manifest.txt TurtleTest3.class Turtle3.class Instructions.class

(then i push enter and it displays a load of info)

TurtleGame.jar

(then it displays the error message i told you about)


Anyone know what i'm doing wrong?


Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
It seems that you have an error/lack of your manifest file. Take a good look at this.


SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
Thank you. I have been doing a lot of reading including the sun tutorials but i'm not seeing what i am doing wrong. That's why i was hoping someone here could point out my mistake.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Have you created the manifest.mf file ?
Does it have a Main-Class entry ?
Does the manifest file end with a new line character?
Have you included it in your jar ?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
Maneesh Godbole wrote:Have you created the manifest.mf file ?
Does it have a Main-Class entry ?
Does the manifest file end with a new line character?
Have you included it in your jar ?



I wote down the exact steps i had taken in my first post. And according the article that i was reading (there is link to that also in the first post) that would create a manifest file and include it in the jar. Right?

I have looked inside the jar file and the manfest is there. I don't know if the way i created it creates a new line character or not. By new line character do you mean \n or that i just type enter?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Can you copy paste the contents of your manifest file? Is it called manifest.mf ?
Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
Maneesh Godbole wrote:Can you copy paste the contents of your manifest file? Is it called manifest.mf ?


The manifest file ends up being simply called manifest.

The contents are just the one line that i will print below...

Main-Class: TurtleTest3


So is the article i am following just wrong and not telling me to do it right?

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Recommended reading http://java.sun.com/docs/books/tutorial/deployment/jar/index.html

TellTheDetails
PostRealCode

You originally mentioned
jar cvfm TurtleGame.jar manifest.txt TurtleTest3.class Turtle3.class Instructions.class

and then you say
The manifest file ends up being simply called manifest.


Kind of difficult with this kind of confusion
Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
Maneesh Godbole wrote:Recommended reading http://java.sun.com/docs/books/tutorial/deployment/jar/index.html

TellTheDetails
PostRealCode

You originally mentioned
jar cvfm TurtleGame.jar manifest.txt TurtleTest3.class Turtle3.class Instructions.class

and then you say
The manifest file ends up being simply called manifest.


Kind of difficult with this kind of confusion



Sorry but those are the exact steps i took... In fact once you said you wanted to know what was written inside the manifest file i needed to make it again so i copy and pasted what i wrote in the first post into the command prompt to create another manifest file in the exact same way and that's how it came out. Called manifest.

You know what, just forget it mate i'll figure it out.




Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150


Oh and i'm very careful in this forum to follow all the rules. I couldn't have told you any more details. I told you exactly what i have done. If there are more details i do not yet have the knowledge to even know what they are. I think some people forget around here what it is like to start learning a completely new topic.




Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Since we cannot see your code, the idea is to get a clear picture by asking stuff.
I asked you
Is it called manifest.mf ?

to which you replied

The manifest file ends up being simply called manifest.
The contents are just the one line that i will print below...
Main-Class: TurtleTest3
So is the article i am following just wrong and not telling me to do it right?


Even as of this moment I do not know if your original file is .mf or .txt or what.
So I provided you a link which I thought you might find useful.

You know what, just forget it mate i'll figure it out

I am sorry I could not rise up to your expectations and I wasted my time. Have a nice day.
Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
Maneesh Godbole wrote:


Even as of this moment I do not know if your original file is .mf or .txt or what.
So I provided you a link which I thought you might find useful.


I guess that's cause i got confused and didn't realise you were asking for the file type so i just told you what the name of the file was when i looked at it.


Maneesh Godbole wrote:I am sorry I could not rise up to your expectations and I wasted my time. Have a nice day.


The only expectation i have is politeness. Thanks for trying to help and sorry to have wasted your time. I hope you try and be little more understanding next time you try and help someone out.

Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

The tutorial you linked isn't good. I recommend you go through the Sun/Oracle tutorial:
http://java.sun.com/docs/books/tutorial/deployment/jar/index.html

In the portion dealing with the manifest, don't miss the repeated warning:
Warning: The text file from which you are creating the manifest must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.

Creating the file by redirecting echo won't do that.


luck, db
There are no new questions, but there may be new answers.
Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
Darryl Burke wrote:The tutorial you linked isn't good. I recommend you go through the Sun/Oracle tutorial:
http://java.sun.com/docs/books/tutorial/deployment/jar/index.html

In the portion dealing with the manifest, don't miss the repeated warning:
Warning: The text file from which you are creating the manifest must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.

Creating the file by redirecting echo won't do that.


Thank you! You've really helped make things clearer for me. I shall have another go when i'm in a better frame of mind. Thanks again.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It really *is* important that we know precisely what the manifest file is called, though: if you're browsing using some sort of explorer application make sure you're not hiding file extensions, or just look in the command line. Or open the file using a zip explorer and report exactly what the name of the file is.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trouble making JAR file that works.
 
Similar Threads
Problem updating the JAR file
How do i get my none programmer friends to try out my simple programs by just clicking on them?
packaging up Swing application into Jar file for distribution
jar issues
jar