File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Jar file preparation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Jar file preparation" Watch "Jar file preparation" New topic

Jar file preparation

Aloke Das

Joined: Mar 19, 2003
Posts: 1
I developed a java programm by useing JBuilder 5.0 and it kept in a package such as 'eis' and other class files remained in classes subdirector of 'eis'. There is a WelcomeFile that I want to come first. Will I need to cut of all classes main method excepting WelcomeFiel? How can I take the WelcomeFile into manifest file? What will be the command for 'jar'?
Hameem Ismail SN

Joined: Mar 25, 2003
Posts: 1
You need not cut any main method from ur class files. U have to create the jar file with manifest inside. That manifest should specify which class file to be executed(ie,which class's main method).
create jar file as
jar cmf <name of the jar> <list of class and other files>
Manifest file should contain following text
Run the jar file as
java -jar <name of the jar>
Payam Fard
Ranch Hand

Joined: Jan 31, 2003
Posts: 75
After you create the jar file, you can change the manifest file as follows:
Create a text file containig only the following line, say you name it change.txt:
Main-Class: WelcomeFile
Then you can run the following command to modify the manifest file:
jar umf yourApp.jar change.txt
Now, you can run the application using the following command:
java -jar yourApp.jar
It would go to the Welcome file's main now.
Good luck,
I agree. Here's the link:
subject: Jar file preparation
jQuery in Action, 3rd edition