Azhar Ahmed, wrote on Facebook that "all soldiers should die and go to hell" following the death of six servicemen in Afghanistan. 20-year-old Ahmed, from Ravensthorpe in West Yorkshire said he did not think his comments were offensive.
District Judge Jane Goodwin disagreed, branding his remarks were "derogatory, disrespectful and inflammatory".
He will now do two hundred and forty hours of community service over a two year period and has been fined £300.
More top news
An endangered black Rhino from a North Yorkshire zoo has arrived in Rwanda to be set free to help safeguard the future of her species.
One person has been killed and four others have been taken to hospital after car crash in East Ardsley, West Yorkshire.
The child, who is from eastern Europe, was in Grant Thorold Park with his family when he was elbowed in the face and racially abused.