i intend to create an executable jar file, this is what i do, and what i get...why?
is all my class file need to be put into a package?

D:\ABC>jar cf chooser.jar *.class

D:\ABC>jar chooser.jar manifest.tmp *.class//this doesnt seem work...

Illegal option: h
Usage: jar {ctxu}[vfm0M] [jar-file] [manifest-file] [-C dir] files ...
    -c  create new archive
    -t  list table of contents for archive
    -x  extract named (or all) files from archive
    -u  update existing archive
    -v  generate verbose output on standard output
    -f  specify archive file name
    -m  include manifest information from specified manifest file
    -0  store only; use no ZIP compression
    -M  do not create a manifest file for the entries
    -i  generate index information for the specified jar files
    -C  change to the specified directory and include the following file
If any file is a directory then it is processed recursively.
The manifest file name and the archive file name needs to be specified
in the same order the 'm' and 'f' flags are specified.

Example 1: to archive two class files into an archive called classes.jar:
       jar cvf classes.jar Foo.class Bar.class
Example 2: use an existing manifest file 'mymanifest' and archive all the
           files in the foo/ directory into 'classes.jar':
       jar cvfm classes.jar mymanifest -C foo/ .
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.

Make sure that when you create a manifest.tmp you include your real main class. Like :

Main-Class : YourMain
InNoCenT_Ch1ldAuthor Commented:
JavaTM, i've read the links you provided already, but when i try it out myself, i got this kind of problem, or my jar wont run! i use javaw and it says that my main class not found?
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Mick BarryJava DeveloperCommented:
make sure you have a couple of blank lines at the end of your manifest
InNoCenT_Ch1ldAuthor Commented:
i tell you what i've done..

i create a mini app just to try JAR out..
my app has around 3-5 classes.. my mainclass is MainFrame
then i do:

D:\ABC>jar cf chooser.jar *.class

after that, i create a manifest.tmp file, in which i type the only line of:
Main-Class : MainFrame

then i do:
D:\ABC>jar chooser.jar manifest.tmp *.class

and the error comes out..

if i try:
D:\ABC>javaw chooser.jar

it says mainclass not found..why?
>> make sure you have a couple of blank lines at the end of your manifest

     :) True, Also make sure that when you are creating your jar file your are
         in the main base directory which has all your classes.
InNoCenT_Ch1ldAuthor Commented:
Now i got this error:

java.io.IOException: invalid header field name: Main-Class
  at java.util.jar.Attributes.read<Attributes.java:362>
  at java.util.jar.Manifest.read<Manifest.java:156>
  at java.util.jar.Manifest.<init><Manifest.java:51>
  at sun.tools.jar.Main.run<Main.java:120>
  at sun.tools.jar.Main.main<Main.java:899>

my manifest.tmp:-
Main-Class : MainFrame

//some blank here..
InNoCenT_Ch1ldAuthor Commented:
all my class files in within the ABC folder..
but all my class don have the package, u know what i mean..(is it the cause of the problem?)

when i run the app using
D:\ABC\java MainFrame

it works...
This regard all that you did just create a manifest file then go to your base directory
Then do this :
    1.) c:\jdk1.4.2\javac\bin\jar chooser.jar manifest.tmp *.class

         The jdk1.4.2 is the jdk version
        // After that do this :

    2.) c:\jdk1.4.2\javac\bin\java -jar Filename.jar

Hope it helps . .
InNoCenT_Ch1ldAuthor Commented:
increase some points
c:\jdk1.4.2\javac\bin\java -jar Filename.jar

should be like :

c:\jdk1.4.2\javac\bin\java -jar chooser.jar

InNoCenT_Ch1ldAuthor Commented:
Failed to load Main-Class attribute from chooser.jar
InNoCenT_Ch1ldAuthor Commented:
arrgggghhh!!!! this is making me crazy!!!! why all ppl can easily create one executable jar file whereas i have to try out all different ways?... does this mean God is trying to talk to me in some way to ask me to give up doing jar???? :(
>> Failed to load Main-Class attribute from chooser.jar

     1.) Try 1st to create a 1 java program or file.
     2.) Make sure you already compile the program.
     3.) Create a manifest.tmp save it on the your main directory.

     4.) On a command promt do this :
          c:\jdk1.4.2\javac\bin\jar chooser.jar manifest.tmp *.class

     5.) After that run the jar like :
          c:\jdk1.4.2\javac\bin\java -jar Filename.jar

Pls. Try this for testing purposes :)
Mick BarryJava DeveloperCommented:
> Main-Class : MainFrame

get rid of the space before the colon

Main-Class: MainFrame

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
>> does this mean God is trying to talk to me
     "Walk through the light and he will show you light, Ask and he shall answer,
      Just believe and you'll have a miracle :)"
InNoCenT_Ch1ldAuthor Commented:
guys guys, it works!! hahaa....
damn it!! just a bloody idiot space spoil everything!!!

in my manifest.tmp
i type:
Main-Class : MainFrame
               this is the bloody idiot space!

i remove it and everything ok!

InNoCenT_Ch1ldAuthor Commented:
i din notice that objects post the comment oledi.. hehe

so, i accept objects comment, izit ok guys?

InNoCenT_Ch1ldAuthor Commented:
Me = Christian,
Javatm = Christian too?
>> i accept objects comment, izit ok guys?
     You should split points but anways I respect your decision :)
InNoCenT_Ch1ldAuthor Commented:
nono... i was thinking just now that i should have post a new empty question for javatm when i was making my cup of coffee.. hahaa..

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

From novice to tech pro — start learning today.