The Jews were commanded to fight specific wars of annihilation against the Canaanites and the Amalekites; but even in
those wars, terms of surrender were offered first, and no one would have been killed if the terms had been accepted. When
the Jews entered Eretz Yisroel, Joshua offered the inhabitants a choice between making peace, fleeing, or fighting (Talmud
Yerushalmi Sheviis 6:1), but peace was conditional on agreeing to observe the seven Noahide commandments, and no
Canaanite group accepted these terms (Joshua 11:19). In fact, Joshua wasn't able to conquer all the Canaanites, and the
ones that remained became a thorn in the side of the Jews (Num. 33:55).
The halacha recognizes "permissible wars" which are waged to acquire additional territory. (These are distinct from
"obligatory wars", which include the original conquest of Eretz Yisroel, the extermination of Amalek, and wars fought in
self-defense.) But such a war can be fought only with the permission of the Sanhedrin, which no longer exists; thus Jews
are allowed to fight wars nowadays only in self-defense. (This may include pre-emptive wars; see Aruch Ha-Shulchan He-Asid 74:1-4.) Wars fought to acquire territory were permissible when there was
a Sanhedrin, but were not genocidal.
Ask a follow-up question