Upvote:9
I found a rather lengthy discussion on this topic at the Internet Encyclopedia of Philosophy. It points out that the concept is most likely to evolve between two culturally similar enemies. The shared values between these two sets of people will result in a situation where "they implicitly or explicitly agree upon limits to their warfare".
The Introduction suggests that just war theory has a long history. It alludes to Homer's *Illiad" and the Bible as sources of examples. The article overall makes for pretty interesting reading. It even expands to discuss the concept of "just conduct within war", in which it basically states that if war is inevitable, there should be certain principles that should be adhered to by the participants.