To compile Java in Google Compute Engine, you must first install a Java Development Kit (JDK) and then use the command line to compile and run your Java program.