File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to create JAR files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to create JAR files" Watch "How to create JAR files" New topic
Author

How to create JAR files

Carlos Delgado
Greenhorn

Joined: Aug 17, 2004
Posts: 15
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.)
Elouise Kivineva
Ranch Hand

Joined: Feb 07, 2002
Posts: 154
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
Chandra Sekhar
Ranch Hand

Joined: Sep 26, 2003
Posts: 90
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


"Luck is when opportunity meets preparation"
Carlos Delgado
Greenhorn

Joined: Aug 17, 2004
Posts: 15
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!
omar bili
Ranch Hand

Joined: Aug 13, 2004
Posts: 177
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

Joined: Aug 17, 2004
Posts: 15
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"?
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Carlos, are you still stuck?

You might like to take a look at the Creating an Executable JAR File thread.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Carlos Delgado
Greenhorn

Joined: Aug 17, 2004
Posts: 15
Originally posted by Dirk Schreckmann:
Carlos, are you still stuck?

No, thanks Dirk. I've already made what I needed.
 
 
subject: How to create JAR files
 
Similar Threads
referencing jars from a jar
jar file problem
A problem about jar ....
How to create an executable in java
problem with struts in weblogic