Japanese prison sentences involving incarceration included forced labor at some task/trade. The exception is prisoners sentenced to death, who are held under the same terms/conditions as people being held in pre-trial detention (except for having more strict restrictions on communications with the outside world). Death row prisoners can't be forced to work because, technically, they are not serving a 窶卍ヲ窶禿ー (choueki) sentence. They don't begin to serve their sentence until the rope stops stretching.
It is common for the goods they produce to be sold either directly to the public or for them to do what amounts to subcontracting for factories. They receive pay for their labor. The latest wage I am aware of is 4 yen per hour, though this info is in all likelihood out of date.
The prisons contract the labor out at a rate which is much higher (200 yen/hour, for example) and pocket the difference.
Here's an interesting little tidbit about Japanese prisoners you aren't likely to encounter anywhere except from your old Uncle Mike: If a prisoner manages to escape from a Japanese prison, the prison authorities have 48 hours to recapture him. If he is still at large more than 48 hours after escaping, they must obtain...get this...an arrest warrant from a court in order to legally apprehend him.