• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

manifest file

 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to create a jar file that knows which class files holds the main() method I want to invoke. I create the txt file as I'm told and jar the files with the appropriate command. However I keep gerring an error. Here's what happens.
What do I keep getting an io exception?

 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should clarify this. I was getting the 'invalid header' message when I had the contents of mainclass.txt as 'Main-Class aul' - no space after the colon. Earlier, when I did have the space, I was getting a 'line too long' exception.
So the obvious problem of my previous post is not the real problem.
Thanks.
Paul
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
post your manifest file.
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea why there is a round green face with a red tongue on the previous post. Obviously I didn't have that in my txt file. I actually had 'Main-Class: Paul'.
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no manifest file because my jar cmf command won't create a jar file with the exception.
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the mainclass.txt file i presume is your manifest file no?
you should put in there somthn like this:
Manifest-Version: 1.0
Main-Class: (the name of your main class )
make sure the main class is the one that has a min method in it. and make sure to use a carrige return (enter) after the last line of the file
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't realize I was supposed to include Manifest-Version: 1.0 in the txt file but even after I did I still get the 'line too long' exception.
My understanding is, whatever I put in the txt file will be taken by the jar cmf command when building the manifest file. The txt file is not the manifest file.
Am I wrong?
Thanks!
Paul
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually u supply the manifest file.
try naming it just manifest for example with no
.txt at the end or anything...
it should matter but what the heck give it a try
and then use the
jar -cmf manifest yourjar.jar *.class
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've just been looking at the source code to see what gives me this exception and the code is checking that I have a '\n' at the end of my line. If I don't I get the exception. But I do have a carriage return at the end of my line. I press return before I save the txt file. Perhaps this is not enough?
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could u just copy paste the manifest file here:
(ie the txt file u have there)..
maybe ill see somthn...
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Main-Class: Paul
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok. lets try this:
make sure again u press enter before u save the manifest file.
and then use this line:
jar cmf manifest yourjar *.class
(notice dont put the .jar at the end of the jar file)
btw, make sure u got a class called Paul in your classes there (just checking).
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I finally got it to work by using the txt extension on the file name.
jar cmf mainclass.txt pj.jar *.class
I could have sworn I tried this already but maybe I hadn't got the carriage return in at the time. All the examples I had seen specifically left out the .txt extension.
I very much appreciate all your help.
Paul
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no problem
btw u did include the txt extension (check out your first post here).
probably didnt have the carrige return then.
 
doug watson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had the same problem and I needed to put a space between the colon and classname like this:
Main-Class: Count
Manifest-Version: 1.0
Created-By: 1.4.0 (Sun Microsystems Inc.)
Main-Class: Count
Then it worked fine.(BTW I am on linux, j2sdk1.4)
jar -umf mymanifest Count.jar
-Doug
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wow. talk about raising the dead
 
Brusk Baran
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
manifest file: i suppose it must have the suffix MF..
regards..
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my manifest manufactured by velocity and ant (I used quotes to show no spaces there. In you mf file, there should be no quotes.
"Manifest-Version: 1.0"
"Main-Class: com.myco.common.Version"
This is the real on inside my meta-inf dir of common.jar. I used ant jar task to build it, which is why ant come into play.
"Manifest-Version: 1.0"
"Main-Class: com.myco.common.Version"
"Created-By: Ant 1.4.1"
[ June 15, 2002: Message edited by: Roseanne Zhang ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic