• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

How to create JAR files

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all! I'm very newbie in Java. I got to do an application for my school where my teacher haven't teached us very well.
My application is finished but I want to know how to create a JAR file.
Is a JAR file an executable file? What's a manifest file?
I've got a main Swing form, several classes, a folder where I put the exception classes and another folder with images (gif).
I've searched in this forum but all questions about this are too complicated to me. I don't want a complicated one, just knowing how to do a simple one.
Thanks in advance!

(Sorry for my english. I'm spanish.)
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look here
http://java.sun.com/docs/books/tutorial/jar/basics/index.html

Lots of answers can generally be found at Sun's java Tutorials & Code Camps area: http://java.sun.com/docs/books/tutorial/index.html
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

The command to create jar file is

jar cvf <jarfilename> folder containing class files/*.*

ex: jar cvf ranch.jar ranchsrcs/*.*

this will also create a manifest file automatically.

U can make jar file executable,ie when u double click on jar to run ur application,u need to give the class name contains main method in ur manifest file.

Edit the manifest file add an entry like
Main-Class: classname

Chandrasekhar
SCJP
 
Carlos Delgado
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
THANKS!!!
I've got this code in a BAT file:

I've got a folder with GIFs called "graficos" and another with the Exceptions called "errors".
As the command JAR creates the MANIFEST but not create the Main Class automatically I've got the external "MANIFEST.MF" with:

which is my main Swing class.
Is all OK?
Thanks again!
 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ,in the manifest you write
the name of the class that contains the main
method. in ur case : formulario
watch out for the spaces
 
Carlos Delgado
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by omar bili:
hi ,in the manifest you write
the name of the class that contains the main
method. in ur case : formulario
watch out for the spaces



Are you meaning that "Main-Class: formulario" should be wrong? Should it be "Main-Class:formulario"?
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Carlos, are you still stuck?

You might like to take a look at the Creating an Executable JAR File thread.
 
Carlos Delgado
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dirk Schreckmann:
Carlos, are you still stuck?


No, thanks Dirk. I've already made what I needed.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic