communication between Arduino and Java

I found the problem. There seems to be a difference between the data the arduino gets from the serial monitor and the data the arduino gets from the serial communication. I used a CR to check the end of the string, this works for data from the serial monitor but not for data from the serial interface (PC). I added another end marker and now it works.
Because the software didn't recieve a CR, the loop never ended and the received data was never send back.