esuslogo
 [To advertise Java(tm) Events here, contact joris@esus.com!]
banner

Java™
by example!






New @ Esus.com


  gb  In-house search engine for better results!

  gb  Get updates with the esus.com
newsletter!









  Home 
 Browse Categories 
 Ask a Java Question 
 Help 
  For Java Tips & Tricks, subscribe to the esus.com newsletter!
Search Java Q&A, Links, API's:   adv 

How do I encapsulate my classes into a jar file?
Example:
c:\java\Main.java:

This code sample is only viewable to esus.com members
Login or become a member!


c:\java\com\esus\io\FileHandler.java:

This code sample is only viewable to esus.com members
Login or become a member!


Compile these two classes. You have two class files: Main.class and com/esus/io/FileHandler.class.
Let's make an executable jar file.


This code sample is only viewable to esus.com members
Login or become a member!


Notice that the jar utility has added the default manifest file, a file that contains
meta information about the files packaged in the JAR (mainly used for security).
The default manifest file looks like this:

This code sample is only viewable to esus.com members
Login or become a member!


Now try to run MyJar.jar:

This code sample is only viewable to esus.com members
Login or become a member!


The error is clear. A jar file usually contains lots of classes (with possibly
multiple main functions). Which one should it pick as the program entry point?
The solution is to provide this information when you create the JAR as an addition
to the default manifest:


This code sample is only viewable to esus.com members
Login or become a member!




Further Information
Author of answer: Joris Van den Bogaert

Comments
Comments to this answer are only viewable by members. Login or become a member!





Terms of Service | Privacy Policy | Contact

Copyright © 2000-2003 Esus.com - All Rights Reserved 
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. Esus.com is independent of Sun Microsystems, Inc. All other trademarks are the sole property of their respective owners.