Friendly enemies such as from the Friendly Ball add flies to the jar, but not those spawned from other enemies.
Batteries do not affect the number of flies in the jar.
Enemies must be actually killed to add a fly; transformations (such as Gapers turning into Pacers) or knockouts (such as incapacitating a Globin) do not count as kills.
With items that kill normally unkillable enemies, killing things like Stone Grimaces will add flies to the jar.
Synergies
Book of Virtues: Using Jar of Flies summons wisps instead of Blue Flies; the wisps do not summon the flies when destroyed. Up to five flies at a time are consumed to summon one wisp, with stacking health and damage. The damage of the wisps decreases as they take damage. Enemies killed by wisps’ tears will not add flies to the jar.
Fish Tail: Doubles the number of flies that spawn.
Hive Mind: Flies are bigger and deal double damage.
Schoolbag: Flies will be gained even while the Jar of Flies is in the inactive slot.
Interactions
Ace Cards: Enemies that are turned into pickups do not grant extra flies.
The item's pickup quote references the tagline of the Pokémon games. The quote said "Gotta catch 'em all?"
With Booster Pack #2, this item's sprite fills up with more flies depending on how many flies it contains. This is based on this Steam Workshop mod by Stewartisme.