I need a good & free compiler for C++ & Java for both Windows & Linux.
Depending on the meaning of the word "good", I would suggest you these:
Most optimized and fastest for Intel CPUs: Intel's C/C++ compiler (which you/your friend can get for free if you obtain an Academic license)
Most standards compliant: GCC
Most integrated with IDE for debugging: MS VC++ (Express edition is free, Professional can be gotten free via an Academic license)
For the first two compilers I'd suggest Eclipse as the IDE.