The invention relates to a method for preventing a
Java program from being decompiled, which comprises the following steps: 1) encrypting a
Java bytecode file to be issued; 2) using a
Java virtual machine tool interface to monitor an initialization event of a
Java virtual machine; 3) designating a Hook function for the initialization event of the
Java virtual machine; 4) when the initialization of the
Java virtual machine is finished, automatically calling the Hook function, and using a Java local interface in the Hook function to register a function called by the Java
virtual machine for generating class objects as a self-defined agent function; 5) when the Java
virtual machine generates a certain class object, calling the self-defined agent function, and decrypting the encrypted
Java bytecode file in the self-defined agent function; and 6) generating a class object corresponding to the decrypted
Java bytecode file, and returning to the Java virtual
machine. The invention solves the technical problem of the limited application range of the method for preventing a
Java bytecode file from being decompiled in the prior art, keeps the cross-platform characteristics of the
Java program and maintains the universality of the Java virtual
machine.