Admittedly, I have never used this (although it's certainly very helpful for debugging - so thanks for this heads up :)), but I just tested it, by changing the Kernel from the JOCLSample.java to
private static String programSource =
"#pragma OPENCL EXTENSION cl_amd_printf : enable"+"
"__kernel void "+
"sampleKernel(__global const float *a,"+
" __global const float *b,"+
" __global float *c)"+
" int gid = get_global_id(0);"+
" printf(\"Test %d\
" c[gid] = a[gid] * b[gid];"+
and it worked for me - that is, it printed out the "Test X" strings.
Of course, the pragma will only work on an AMD platform. For Intel, there is an analogous "cl_intel_printf" pragma. I did not find one for NVIDIA, though, and the attempt to use the given pragma resulted in an CL_INVALID_BINARY error.
Do you have an AMD card? If yes, which problems did you encounter when trying to use this pragma?