Really Stupid... but how do I create a jar file?

Hello,
I feel really dumb for asking this question. But can someone give me a step by step to create a jar file from a set of classes. Everytime I try to I end up with manifest problems, and have been unable to successfully create a jar file.

Cheers,
Rick
richardsimnettAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

petmagdyCommented:
do this on ur code root directory
% jar cf myjarfile *.class

a jar named myjarfile.jar will be generated
but first make sure that ur JDK bin directory is in ur PATH enviroment
0
kiranhkCommented:
first have your path pointed to JDK/bin directory
then execute this command

jar -cvf yourjarname.jar yourfolder or .

like

jar -cvf test.jar .

jar -cvf test.jar c:\test
0
objectsCommented:
grab a copy of ant, it'll handle all your build tasks for you.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

CEHJCommented:
>>Everytime I try to I end up with manifest problems

What kind?

jar cfm yourfile.jar yourman.mf *.class
0
objectsCommented:
0
JonathanJonasCommented:
Another low-tech way to do it is to add your .class files to a .zip file using WinZip or other compression program and then rename the .zip file to a .jar file.

Almost seems too simple but it works :-)

Cheers,

Jonathan
0
kupra1Commented:
the easiest way to learn by itself is first add ur jdk/bin path in ur PATH variable. next type only jar on the command prompt and enter. It will list you all the options and th required parameters, so that you can play around with it.
Example:
If you want to add two classes A.java and B.java into the jar file named Sample.jar, execute:
jar cvf Sample.jar A.java B.java

If you want to use an existing manifest file, named as testmanifest, and want to archive all the files in the folder test into Sample.jar, execute:
jar cvfm Sample.jar testmanifest -C test/ .


0
richardsimnettAuthor Commented:
Hey guys,
Sorry about the dealy in responding to your posts. I have tried all of the above methods.. and all result in the same error:


C:\Documents and Settings\Administrator\Desktop\websites\mailpro\MPFeeder>java -
jar mpfeeder
Failed to load Main-Class manifest attribute from
mpfeeder

This is the same result as I have always gotten. What am I doing wrong here?

Cheers,
Rick
0
objectsCommented:
Try adding a couple of lines to the bottom of your manifest file
And make sure your manifest contains the Main-Class attribute

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
richardsimnettAuthor Commented:
Objects,
Doesnt java automatically generate a manifest? I havent written one.. dont really know how either....

Cheers,
Rick
0
objectsCommented:
It does, but it doesn't include the Main-Class: attribute required for it to be executable.
(As it has no way of knowing which class should be run, if any)
0
objectsCommented:
see the tutorial i posted above for a run down.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.