The best thing would be searching for ...
java discrete cosine transform[
^]; I used google but other search engines are available.
Read up and follow the examples, I don't know how useful any of the results are as I don't know where you have a problem.
Try something, have a fiddle with the code and see what happens.
Then, and only then, come back with a specific problem.