File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating a JAR manifest

 
Neil Laurance
Ranch Hand
Posts: 183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am playing around with creating a stand-alone JAR file, to be run like:
java -jar hello.jar
My jar file only contains:

Where the manifest was created automatically using:
$ jar cvf hello.jar com/neil/Hello.class
Now, running like:
$ java -cp hello.jar com.nkl.Hello works
But, I tried extracting the MANIFEST.MF file, and adding:
Main-Class: com.neil.Hello
Tyring to overwrite the MANIFEST.MF back into the jar file doesn't seem to work. The error I get is:
$ jar umf hello.jar META-INF/MANIFEST.MF
java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:354)
at java.util.jar.Manifest.read(Manifest.java:161)
at java.util.jar.Manifest.<init>(Manifest.java:56)
at sun.tools.jar.Main.update(Main.java:487)
at sun.tools.jar.Main.run(Main.java:168)
at sun.tools.jar.Main.main(Main.java:904)
Anyone point me to a good manifest ref?
Thanks Neil
[ September 13, 2002: Message edited by: Neil Laurance ]
 
Neil Laurance
Ranch Hand
Posts: 183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I sussed it. Eventually
 
djoejoe
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok this is just some of the basics lets say you have a .class called helloworld and you are useing the jdk
to put that class into a jar you would do something like this at the commandline
jar cf aname.jar helloworld.class
this would that class, note this class has the main()mothod in it.
now let make that jar runnable and change the mainifest file
We mak a txt file called mf.txt and we put this in there
Manifest-Version: 1.0
Main-Class: myjar
Name :myjar
and save it now at the commandline we
do this
jar umf mf.txt aname.jar
and this should change the mainfest file that was made by default for you and it should make your jar double clickable for windows

ps I hope this helps
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
djoejoe,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, what does I sussed it. mean?
 
Joe Joe
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made a bobo
Where you see this
Manifest-Version: 1.0
Main-Class: myjar
Name :myjar
where you see myjar it should be helloworld cause that would be your main class that has the main() method
anyways see you around partner
 
Neil Laurance
Ranch Hand
Posts: 183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dirk Schreckmann:
So, what does I sussed it. mean?

Its English slang for: I figured it out. I played around with the order of the arguments to the jar command, and got it to work
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic