PARIS (Reuters) - A teenager who attacked a Jewish teacher in France with a machete was sentenced to seven years in jail on Thursday by a French juvenile court, judicial sources said.

The 17-year-old was convicted at a closed-doors trial for slightly wounding the teacher who was wearing a traditional Jewish skullcap, or yarmulke, while walking to school in January 2016 in the southern city of Marseille.

Prosecutor Brice Robin said shortly after the attack that the teenager, who has not been identified because of his age, said he had acted in the name of the Islamic State militant group.

The teenager, a Turkish citizen of Kurdish origin, was 15 at the time of the attack. He was charged with attempted murder in connection with a terrorist attack, with the aggravating factor of anti-semitism.

The head of the Jewish community in Marseille advised Jews in the city soon after the attack to avoid wearing the kippa (yarmulke) in the streets. “It really hurts to reach that point but I don’t want anyone to die in Marseille because they have a kippa on their head,” Zvi Ammar told La Provence daily.

France is home to both the largest Jewish and the largest Muslim populations in Europe.

Islamic State has claimed responsibility for a number of large-scale attacks in France, including a truck attack that killed 86 people in the Riviera resort of Nice in July 2016 and a coordinated series of attacks in Paris in November 2015 in which 130 people were killed.