"(The defendants) have been proven guilty beyond reasonable doubt of displaying nudity and sexual exploitation collectively in public," said the documents, which have been reviewed by AFP.

The North Jakarta Court also ordered the defendants to pay one billion rupiah ($73,700) in fines.

The sentencing is further evidence of growing hostility towards Indonesia's small lesbian, gay, bisexual and transgender (LGBT) community.

Homosexuality and gay sex are legal everywhere in Indonesia except in conservative Aceh province, but police have used the country's tough anti-pornography laws or drugs charges to criminalise LGBT people in the past 18 months.

Rights groups condemned the decision to jail the men.

"It is an abuse of these gay men's rights. It is not a crime, they did not hurt anyone," said Andreas Harsono, a Human Rights Watch researcher in Jakarta.

The men, who were tried in two separate closed court hearings, were sentenced the same day the Indonesian Constitutional Court rejected a bid to outlaw extramarital sex.

The unsuccessful petition would have affected both unmarried heterosexuals and gay people, who cannot marry in Indonesia. Its rejection was seen as a victory by LGBT communities.

Jakarta’s Community Legal Aid Institute, which often provide legal assistance to LGBT-related cases, said the timing was ironic.

"While the Constitutional Court said social norms should not be addressed using law enforcement, the North Jakarta court sentenced these people using such a problematic law," its director Ricky Gunawan told AFP.