File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes How to create Jar file[Greenhorn] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to create Jar file[Greenhorn]" Watch "How to create Jar file[Greenhorn]" New topic

How to create Jar file[Greenhorn]

Kris Danielewski

Joined: Apr 01, 2009
Posts: 25
I have seen few examples online but i can;t make my own jar file...
I aslo searched forum , however found only more advanced related topics...
Could someone please write to me step by step how to do it?
My class name (contains main)
John de Michele

Joined: Mar 09, 2009
Posts: 600

Try this page.

K. Tsang

Joined: Sep 13, 2007
Posts: 3130

Hi Kris, you should check out the help for the jar command "jar -help"

Simple example: "java cvfm <filename>.jar manifest.txt -C classes ." or "jar cvfe <filename>.jar <main class with full package> -C classes ."

classes is the directory containing all .class files. The period "." represents everything in that directory. The manifest file contains what the main class, classpath if any etc

Sample manifest:

K. Tsang JavaRanch SCJP5 SCJD OCPJP7 OCPWCD5 OCPBCD5 OCPWSD5 OCMJEA5 part 1 part 2/3
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10815


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
I agree. Here's the link:
subject: How to create Jar file[Greenhorn]
It's not a secret anymore!