Java's printing API pretty much "assumes" 72dpi, even though it can print to printers with a much higher resolution then this.
This makes things much easier, as you simply don't need to care.
Essentially, you can convert cm to pixels by converting to dpi...
double cms = 5;
pixels = (cms * 0.393700787d) * 72
// 0.393700787d is the number of cms per inch ;)
Take a look at How to design an image in java to be printed on a 300 dpi printer for further details