Learning Objectives:
- Create an executable file of your game.
- Demonstrate the use of polymorphism.
Once you’ve developed a game, you’ll want to package it into
an executable file for users to run on their computers. One way to do this is to export your package as
a runnable *.jar file. The steps to do this are different depending
on which IDE you use (VSCode, Eclipse, etc).
In VSCode,
open the command palette by typing (⇧⌘P) or (Ctrl-Shift-P) and enter:
In VSCode,
open the command palette by typing (⇧⌘P) or (Ctrl-Shift-P) and enter:
java: export jarOr click the Export Jar button:

To run the jar file, from a Terminal, type:
java -jar filenameIn Eclipse,
- Select "Package Export"
- Select "Java"
- Select "Runnable jar file"
- For run configuration, select "controller"
- For export destination, select "Downloads"
- Select "package required libraries into generated jar"
- From a Terminal, type "java -jar filename"
Challenges
Challenge 7A_SpaceAliensComplete
Enhance your Space Aliens game to include the following features:
- A start screen which asks for and allows the user to enter their name.
- Occasionally a boss-alien (use your own sprite) should traverse the top of the screen, which should be destroyable by the spaceship with a missile.
- The user should be able to play multiple levels. Each level of play should have different game behavior (speed of aliens, boss-aliens, etc.). Be creative!
- A scoring system should be incorporated into the game, keeping track of aliens killed (1 point each) and the boss-alien (10 points) destroyed at each level.
- Display an end screen showing the current user’s name and score.
Challenge 7B_SpaceAliensPlus
Enhance your Space Aliens game per 7A and in addition, include the following bonus features:
- At startup, display a screen showing the top three user names and high scores. Use a fake list to begin with.
- Allow the user to enter their name at the beginning. Then use persistent storage to keep track of the three highest scores on the machine to display upon restart of the game.
The game should have a class that contains all scores (ScoreBoard). This ScoreBoard class should be Serializable, which means it can be written to disk using the writeObject() method. Once written to disk, it can be read back with the readObject() method. See page 617 in Absolute Java by Walter Savitch.