• 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

How to make up several java file to one *.jar file ? with programing

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like the title,I have a project with serveral java file, then I want to make up them to one *.jar file with programing.
I have put the serveral java files into one File(AlimonyGather), and use commands "jar cvf A.jar AlimonyGather "
But the A.jar warning that "Failed to load Main-Class".
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using Java 6, you can use the entrypoint flag (e) to specify the main class. Otherwise you will have to create a manifest file in your jar file. Here's a tutorial http://download.oracle.com/javase/tutorial/deployment/jar/appman.html that describes both.
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, your class path is at the top level. Therefore, you should add your top level package folder to your Jar.
AlimonyGather doesn't look like a package name.

Let's say your main class is com.example.alimony.Main.

Then try this:

jar -cfe A.jar com.example.alimony.Main com/example/alimony
 
reply
    Bookmark Topic Watch Topic
  • New Topic