This sounds like a job for socket communication. Your Java program can establish a java.net.ServerSocket and listen for requests from the C program. Once a connection is established, start a
Thread to accept the data from the C program, process it and return the result.
I believe we have a whole forum here for socket related programming.
Bill