Mohamed Urgus Adeysey, 23, and Abdinur Hussain Ali, 38, were sentenced on Friday in Tokyo's district court in the country's first piracy trial.
Both had pleaded guilty to the attempted hijacking of the 106,000-dwt Guanabara (built 2007) in the Gulf of Aden.
The men's legal team had wanted a suspended sentence, but prosecutors were calling for jail terms of 12 years.
“The defence lawyers argued that severely punishing the defendants, who were part of a gang of pirates, will not be a solution to the problem of Somali pirates, and that it requires political and economic support for Somalia.