|
Java™ by example!
|
|
|
How do I encapsulate my classes into a jar file?
Example: c:\java\Main.java:
c:\java\com\esus\io\FileHandler.java:
Compile these two classes. You have two class files: Main.class and com/esus/io/FileHandler.class. Let's make an executable jar file.
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:
Now try to run MyJar.jar:
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:
Further Information
Author of answer: Joris Van den Bogaert
Comments
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|