To answer your question I would invoke the Bhagavad Gita, and the conversation between Arjuna and Krishna at the beginning over "what is one's dharma (duty)?" At the start of the poem, Arjuna says that after reflecting on the unity of being, he does not wish to spill blood or be a warrior any longer. He wants to renounce violence altogether. Perhaps surprisingly, Krishna admonishes Arjuna for refusing to fight: and the god goes into a long defense of why it is his duty to take up the sword and go into battle. Otherwise, says Krishna, he is unmanly and cowardly, and is betraying his country and destiny by refusing to fight.
I believe the Arjuna character is vocalizing the intuition many of us feel from our higher nature: that war, destruction, and violence are evil and futile. Arjuna states the desire to give up war. He feels he should become a mendicant, and dedicate himself to peace, philosophy, and spiritual matters, which is a noble end.
If we look at the history of war, most were waged for the benefit of a small number of rich people; or they were initiated based on misunderstanding or prejudice. They involve mutilation, PTSD, brain injury, and the deaths of young people and family members. Most wars end in an impasse with little to nothing accomplished. World War I is one famous example.
If we invoke Christianity, Christ vocalizes the same themes as The Gita. In one section he says to "turn the other cheek" and to "not resist the evildoer": a call to the discipline of pacifism. He says "those who live by the sword will die by the sword": a correct prescription for the fate of the violent. Later, however, Christ changes. He says to his disciples that those who "did not have a purse should get one," and if one did not have a sword one should "sell one's cloak and buy one."
I believe Christ is getting at an important formula for the spiritual life. There is a practice of self-discipline that for a long time requires nonviolence. This practice overcomes something deep and unethical in human nature. However, when the discipline is complete, which occurs when the master states, the strict following of this changes. I believe this is why Christ later says it is OK for normal morality to re-assert itself, and for it to be OK to practice self-defense.
The moral complexity and ambiguity of the answer - the struggle to identify and achieve justice - is the human condition. It is one's duty to defend one's country if it is invaded. The path of the soldier can be noble and virtuous. However, the unity of being affirms the immorality of violence and bloodshed, and that those who live by the sword will die by it.