Space Battle Arena

A Programming Game in Java for AP CS Students.

Download Client Jar Java Docs Download Server (Windows) View on GitHub

Command Line Client Environment Setup


This document provides instructions for running ships on the command line using javac and java.

These instructions were prepared for Java 1.7 and above.

Initial Setup

Create a Spaceship class:

import java.awt.Color;

import ihs.apcs.spacebattle.*;
import ihs.apcs.spacebattle.commands.*;

public class ExampleShip extends BasicSpaceship {
    public static void main(String[] args)
    {"", new ExampleShip());

    public RegistrationData registerShip(int numImages, int worldWidth, int worldHeight)
        return new RegistrationData("Example Ship", new Color(255, 255, 255), 0);
    public ShipCommand getNextCommand(BasicEnvironment env)
        return new IdleCommand(0.1);
  1. Be sure to have the gson-2.2.jar and SpaceBattle.jar in a known location (e.g. a 'lib' subdirectory).

  2. Open a Command Prompt.

Execution Instructions

Note: Do not terminate the program with Ctrl+C; instead, type 'QUIT' to gracefully close the connection.

  1. Compile your code with the following command:

    javac -cp lib\SpaceBattle.jar;lib\gson-2.2.jar
  2. Run your code with the following command:

    java -cp lib\SpaceBattle.jar;lib\gson-2.2.jar;. ExampleShip

    Note: the addition of the ';.' this is to represent the location of your compiled class file.

  3. Type 'QUIT' in the console window to disconnect your ship.