The invention provides a Java code generating method. In the method, a template module, a data analyzing module, a code generating module and a data module are needed, and an automatic source code generating script is defined in the code generating module. A specific operating method comprises the following steps: extracting metadata, defining the metadata to form a metadata file, and storing in the data module; extracting the metadata file by using the data analyzing module, analyzing the metadata, acquiring the code template from the template module, and converting the metadata into a template object, wherein the code template is provided with a named parameter used for identifying the template object; and executing the automatic source code generating script by using the code generating module, assigning the named parameter in the code template by using the template object to generate a plurality of source code files, and storing the source code files at positions corresponding to the metadata file in the data module. The Java code generating method has the advantages of high maintainability, high code consistency, high reusability, higher development efficiency and lower manpower cost.