I assume you have a game loop something like:
while( running ) {
doStuff();
paint();
waitForNextTick(); //?
}
You just need add a counter, and some time checking.
int fps = 0;
long lastFPS = System.currentTimeInMills() + ONE_SECOND_IN_MILLS;
while( running ) {
doStuff();
paint();
waitForNextTick();
fps++;
if( lastFPS < System.currentTimeInMills() ) {
System.out.println( fps );
fps=0;
lastFPS = System.currentTimeInMills() + ONE_SECOND_IN_MILLS;
}
}