A just war occurs when a country has invaded the boundaries of another and the invaded country fights to protect itself and rid itself of the invaders. It may also be when the invaded country asks for help from an ally, that the ally fights against the invading country. Our involvement in South Korea in the 1950s would be an example.
The U.S. has not been invaded by a foreign country in recent times, yet we seem to wind up in some form of warfare quite often. The situation in Iraq would be an example, where no political sovereignty invited us to join in an invasion of that country. Yet seven years later we are still there. The U.S. government judged the Iraqi government to be an evil one, so the U.S. decided to overthrow that government. It can be argued that the invasion by us constituted an unjust war.
Countries go to war to expand their boundaries, control resources, or extend their influence. Perhaps they go to war for all three reasons, once the fog of rhetoric is lifted. Typcially the arugments, at least in the US, center around some underdog struggling under the heel of some oppressor -- and since we have the might, we ought to make right. So Mexicans are bothering Texans, so we go to war. So Spain is oppressing its Filipinos and Caribbeans, so we go to war. So the freedom loving democratic South Vietnamese are being subjegated by the godless communists of Red China, so we go to war.
However, when the British subjegated the colonies, we went to war. When they intercepted our merchant fleet we went to war again in 1812. When the South had had enough of the North they broke away in 1861. When Germany proposed aiding Mexico in 1917 to retake its territory lost to the US in 1846, again we went to war.
The only justifiable war is defensive -- the Revolution, War of 1812, the Confederate States of America. The justification for war diminishes the further a country sends its armed forces. Excepting the anomalies of both world wars, when you must invade wholesale or ship troops far from the homeland, you're on increasingly shaky ground, physically and morally.
I agree with the other two answers that it is hard to define a just war, but I believe that there are clearly wars that are unjust. By this I mean that there are wars that are entered into for unjust reasons.
To me, an unjust war is one entered into for no purpose other than to increase a country's power. I would argue that such wars as the Mexican-American War, the German actions to start WWI and WWII, and the Soviet invasion of Afghanistan were started for such unjust and selfish reasons.
As for US wars, I would go with answer #1 -- the US tends to go to war for just reasons, but seems to do so rather unwisely. Vietnam, Iraq, Afghanistan -- all of these wars were undertaken for relatively unselfish reasons. But you could equally argue that all of them were undertaken in rather foolish ways.
To a great extent, all wars are declared as "just wars" by those who are waging them. I am not certain there has been a war declared in the United States, or any nation, which has been openly justified as "We are seeking to enhance our own wealth and solidify our own prestige." Having said that, there is a thought that believes that the people who wage wars are not the same people who fight them. With this, I feel awkward about outwardly judging any war that has been waged because the individuals who had to do the fighting in these wars, those who had to make the ultimate sacrifice in body and mind, were probably not consulted in the situation room about the war. This means, that these warriors could have believed in the just nature of the war that they were commissioned to fight. For example, many feel that the war in Vietnam was not just and was not fought for anything other than national greed or fear. Yet, it seems beyond insensitive and harsh to make such a statement in the face of the soldiers who fought and sacrificed in the name of this cause. Certainly, one could make the case that wars have a justification attached to them by leaders who wage them which pleads fairness, justice, and the restoration or establishment of structure and order. The rationale offered in these conflicts create the presence of a just war. The realities might be very different. Yet, in light of those who have to give their lives without any sense of consultation, I would say that these forces might be the walking proof of the attempts to justify an endeavor which, at its core, holds little in way of justification.
There are always minimum two parties involved in a war, and what is claimed to be just cause by one party to the war is considered to be highly unjust by the other.
There is no war in which all the parties of the war claiming their cause to be just, and that of opponents to be unjust. Thus it is difficult to to classify wars as just or unjust. I would prefer to qualify wars as wise or unwise. Just to illustrate, take the case of Azad Hind Fauj, an army raised by Netaji Subhash Chandra Bose for liberation of India from the British, joined hands with the Japanese and Germans during the World War II. The cause of Azad Hind Fauj, in my opinion was very much just, and many great Indian leaders, including people like Mahatma Gandhi, Jawaharlal Nehru, and Sardar Patel, espoused this cause. However, waging of war by Azad Hind Fauj to accomplish its objectives was, perhaps, unwise.
Coming to specific case of post World War II wars of USA in places like Vietnam, Afghanistan and Iraq, Even if we accept the objective of these wars to be just those noble ones as contained in many official communications, many of the actions taken do not appear to be very wise or that much in line with the publicly declared just causes.