Creating a JAR File
Once you have successfully completed your programming assignment, you
will
need to create a JAR file to submit your assignment. This
will help us grade your assignment. You will lose points if you do
not
submit your programming assignments in a JAR file.
Instructions for checking your JAR file
What is a JAR File?
JAR stands for "Java Archive." It is much like a compressed ZIP file
that
you may have used before. You will be adding each Java source file in
your
assignment (usually only one file, sometimes more) to a JAR file before submitting.
The size of the final JAR file will be smaller than the original programs
and therefore be easier to e-mail.
How Do I Create a JAR File?
- Choose Create JAR File For Project from the Project
menu
in jGRASP.
-
The Create JAR File for Project dialog box should open.
Make sure the only checkbox that is checked on is labeled Sources.
The other checkboxes should be off. The .java files that you added earlier
should appear as shown below. If they do not, click Add to add your
.java files for the current assignment. Click Next.
-
A new dialog box will open asking for the name of the JAR file to create.
You should name the file yourlastname_assign#.jar (for example,
kohli_lab1.jar
or kohli_prg1.jar
). Make sure
that the JAR file ends in .jar and that the file is being created in
the same folder as your Java source files. Once you have appropriately
named your JAR file, click Create JAR.
How Do I Check to Make Sure My JAR File is
Correct?
-
After you've completed the steps above, your
JAR file
should appear in the list of files on the left side of your jGRASP
window.
-
Choose JAR/Zip Extractor from the Project
menu.
-
In the JAR/Zip Extractor window, click on the folder icon.
-
In the Open File dialog box that appears, chose the JAR file
that you just created and click Open.
-
If you see the names of your Java source files in the JAR/Zip
Extractor window, you have successfully created your JAR file. (You
may also see some other files, like "META-INF" and "MANIFEST.MF" in the
window.) Double-check the Modified date to make sure that you've put
the latest version of your Java source file in the JAR file. You can
now close the JAR/Zip Extractor window.