If a Hindu was a soldier, would it be against his ahimsa to kill, even though it may be necessary?
It is not against the idea of non-violence in hinduism to reply with full force if one is attacked or in defense of justice. Not doing so would be cowardice and a sin. That is the whole message of one of the most important of the hindu scriptures - Bhagawat Gita. Lord Krishna said:
"Atha chet tvam imaḿ dharmyaḿ, sańgrāmaḿ na kariṣyasi;
tataḥ sva-dharmaḿ kīrtiḿ cha, hitvā pāpam avāpsyasi."
(Therefore, if you do not perform your this religious duty of fighting, then loosing your duty and reputation, you will incur sin.) http://www.vedabase.org./bg/2/33/en
Hinduism is a practical religion. With best regards,