IMGD 4000 (D 08)
Step-by-Step Instructions
for Preparing Homework Jar File
The following assumes you have installed jME using Eclipse as per the
recommended
instructions, and that you have created a separate project, named 'chess' for
your homework (which 'requires' the jme project). Adjust appropriately if your conditions are different.
Hint: In order to make a self-contained executable jar file, you will need to load all your art assets as resources (e.g., using Class.getResource()), which basically means putting them on your classpath. If you are not familiar with the general concept of resource loading in Java, here's a good tutorial article.
Don't forget to update your javadoc (Project>Generate Javadoc) and toplevel
README.txt file before creating a jar file!
PART A: INITIAL SETUP (Only Done Once)
- Create a new folder named 'turnin' at toplevel in your homework project (subfolder of 'chess'):
- File > New Folder
- [Select 'chess' as parent folder]
- [Enter 'turnin' into Folder Name field]
- Finish
- Create a template manifest file in the turnin folder:
- File > New File
- [Enter 'manifest.mf' into File name field]
- Finish
- Add the following three lines to the manifest file:
Manifest-Version: 1.0
Class-Path: ../../jme/bin/ ../../jme/lib/lwjgl.jar
Main-Class: mypkg/MyClass
Where 'mypkg/MyClass' is replaced by the fully-qualified name of your main class (using slashes instead of dots).
- Make sure there is a real carriage return at the end of the last line of the manifest file.
- Cutting and pasting the lines above into an Eclipse buffer has been observed to introduce "bad" carriage returns, which cause the Main-Class line not to be recognized by Java.
- Make sure the folder name 'jme' above matches the folder name (including capitalization) of your jME project folder.
- Export your homework project as a jar file in the turnin folder:
- File > Export > JAR file > Next
- Select 'chess' project.
- Expand subfolders and de-select the 'turnin' folder and any other files or folders that are not required to run the application, except for the source ('java'), binary ('class'), javadoc ('doc') folders and the README.txt file, to avoid bloating your jar file.
- Make sure both "Export generated class files.." and "Export java source files..." are checked.
- Enter 'chess/turnin/hello.jar' in JAR file field
- Next > Next
- Select "Use existing manifest..."
- Enter 'chess/turnin/manifest.mf' in Manifest file field.
- Finish
- Verify that the jar file is runnable:
- Upload the jar file (only) via Web Turn-In.
PART B: TO CREATE NEW JAR FILE EACH TIME
- File > Export > JAR file > Next
- Select 'chess' project.
- Expand subfolders and make sure folders de-selected in Part A (3) above are still de-selected.
- Change JAR file name as appropriate (keep old versions of assignments for reference)
- Finish
- Verify that the jar file is runnable as in Part A (5) above (with appropriate jar file name).
- Upload the jar file (only) via Web Turn-In.