A mechanism is provided for optimizing computer program execution during class loading phase. As a code method of the program is received for compiling prior to execution, a check is performed whether program execution is in class loading phase. Program execution is in class loading phase where the class loading rate exceeds a pre-determined level during a pre-determined interval. If the program is in class loading phase, then compiling is reduced by lowering frequency of just-in-time (JIT) compilation, lowering optimization level of just-in-time compilation, or a combination of the two. The code method may also be passed to an interpreter to be interpreted.