Jacks are additional national flags flown by warships (and certain other vessels) at the head of the ship. These are usually flown while not underway and when the ship is dressed on special occasions. Jacks in the Royal Navy must be run up when the first line is ashore when coming alongside.
Apparently the British navy started this.