Countries go to war for a lot of reasons these days. Turkey invaded Syria to keep the Kurds from declaring it to be their homeland. The United States and The United Kingdom almost went to war over a pig. Some 2,000 people died in the fighting between two Italian states because someone stole a bucket. While those are all dumb, there are some good reasons to fight a war, and that's what the "Just War" philosophers have been working on forever.
Over the years, a number of principles have been boiled down from the world of philosophy addressing the subject, as everyone from Saint Thomas Aquinas to NPR have produced their thoughts on the ethics of killing in uniforms. See if your favorite war fits the criteria!
Get in losers, we're gonna go liberate Kuwait.
It has to be a last resort.
The only way to justify the use of force is to exhaust all other options. If the enemy could be talked down from doing whatever it is they're doing instead of fighting them to stop them by force, the war can't be justifiable. In Desert Storm, for example, President Bush gave Saddam Hussein a time limit to remove his forces from Kuwait before bringing down the thunder, that just didn't persuade Hussein.
It must be declared by a legitimate authority.
Some countries have very specific rules about this. A war cannot be declared by just anyone. What may be egregious to one person or group may not apply equally to the country as a whole, and the rest of the world needs to recognize the need and the legitimacy of the actions taken as well as the authority of those who send their people to war.
A just war is fought to right a wrong.
If someone attacks you out of the blue, you are completely within your right to defend yourself by any means necessary. If a country is seeking to redress a wrong committed against it, then war is justifiable. When the Japanese Empire attacked the U.S. naval base at Pearl Harbor in 1941, it was sufficient enough to send the United States to war.
You have to have a shot at winning it.
Even if one country sucker-punches another or has good intentions in its decision to go to war, it's not a justified war if that country cannot win it. If fighting a war is a hopeless cause, and the country is just going to send men to their deaths for no end, it cannot be morally justified.
It's also kind of dickish to do that to your population.
The goal of the war should be to restore peace.
If you're going to war, the postwar peace you seek has to be better than the peace your country is currently experiencing. Of course, Germany thought going to war in World War II was a just cause. The Treaty of Versailles was really unkind to them. Does it mean they were allowed to kill off the population of Eastern Europe for living space? Absolutely not.
You should only be as violent as you have to be to right the wrongs.
Remember, if you're going to start a just war, you're fighting to right a wrong, to redress a grievance. If you start the wholesale slaughter of enemy troops, that's not a just war by any means. The violence and force used by one country against another have to be equal.
Only kill the combatants.
It seems like a foregone conclusion that an invading force shouldn't murder enemy civilians, but looking at history – especially recent history – it looks like that's what it's come to. A legitimate warrior only kills those on the enemy's forces who are lawful combatants.