PDA

View Full Version : To create jar file in java


ubharedev
Oct 5, 2010, 02:32 AM
Hi,
I want to create an executable file for my console application program.
It is a network file sharing program, need to run on double click or command line.
This program contains 11 class files in which FileSharing.class is the main class file.
I have created manifest.txt file with 'Class-Path: Test1/FileSharing.class' as main class file where Test1 is the package.

Then I run the command: jar cfm FileShare.jar manifest.txt *.class
I creates a jar file with FileShare.jar name.
But while giving the run command from cmd.
java -jar FileShare.jar or java -jar FileShare
Gives the following error:
Unrecognized option: -
Could not create the Java virtual machine.

Please help.

Regards,
Dev

ubharedev
Oct 8, 2010, 02:05 AM
Ok.
I got the answer.
Go to the folder where u put all class files in command prompt.
Create manifest file.
Type in command prompt: jar cfm jarfilename.jar manifestfilename.txt *.class
Finish.