• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

trouble creating jar file

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I keep getting a "Can't find main class. Program will exit".

This is what I have:

Copy.java has been compiled to copy.class. Here is the source code:




I wrote a custom manifest file that has these lines of code:

Manifest-version: 1.0
Main-Class: Copy
Created-By: 1.4.2_09 (Sun Microsystems Inc.)

I used windows command line to compile, using this:
jar cmf c:\Manifest.mf c:\Copy.jar C:\Copy.class

Please help!
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When do you get that error? Does it happen when you run the jar program to create the jar file or when you try to run the program after you created the jar file?

Layne
 
Mike Harris
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get the error after I have created the jar file and I try to execute the .jar
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> jar cmf c:\Manifest.mf c:\Copy.jar C:\Copy.class

Try this:

jar cmf c:\Copy.jar c:\Manifest.mf C:\Copy.class

(the name of the JAR file first, then the manifest file).

How are you trying to run your JAR? I guess with this:

java -jar Copy.jar
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once you create a jar file, run the following command:

jar tf Copy.jar

This will show the contents of the jar file so you can verify that it contains the files you expect.

Also, we need to know how you execute the jar file? Do you use the command that Jesper gave above?

Layne
 
reply
    Bookmark Topic Watch Topic
  • New Topic