• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Updating a JAR manifest

 
Ranch Hand
Posts: 183
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I sussed it. Eventually
 
Greenhorn
Posts: 1
  • 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
 
Sheriff
Posts: 7023
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, what does I sussed it. mean?
 
Greenhorn
Posts: 5
  • 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
  • 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
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic