Creating a Jar File 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 me grade your assignment. You will lose points if you do not submit your programming assignments in a JAR file. * To check the contents of your JAR file, open it with an Archive Reader, such as WinZip, WinRAR, or Windows Archive Manager Please be sure that your JAR file contains both the class file(s) and the java file(s) needed for the assignment. * To check that your MANIFEST file is correct, you can run your jar file. To do this, open a C: Prompt (Windows) or the Terminal application (MAC) and change your directory to the location of your jar file. (Google how to do this if you do not know). Then type in the following command: java -jar nameofyourjarfile.jar What's a Jar File? Jar stands for "Java Archive". It's much like a compressed ZIP file that you may have used before. You'll be adding each Java source file in your assignment (usually only one file) 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? In Eclipse, highlight your Project name and select File -> New -> Folder -Name the Folder META-INF and Click Finish Create a New File inside of META-INF named MANIFEST.MF Copy the following into MANIFEST.MF (make sure the last line in the file is a blank line, i.e. one extra blank line) Manifest-Version: 1.0 Class-Path: . Main-Class: Bluth (replace Bluth with the name of your Java class) Here is an example MF file for FirstProgram: MANIFEST.MF After you've successfully compiled, run, tested, and commented your program, highlight your Project name and select File->Export Select Java -> JAR file and Click Next Check the boxes for both "Export generated class files and resources" and "Export Java source files and resources" Choose a Location to save the JAR file (be sure to name the file lastname_prg#.jar)(if you do not specify a folder, it will be saved in your Eclipse workspace) Click Next Check the boxes for both "Export class files with compile errors" and "Export class files with compile warnings" Click Next Choose "Use existing manifest from workspace" and Browse for the MANIFEST.MF file you created earlier under META-INF Click Finish When you submit your assignment, you will only need to submit the JAR file.