Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the development and operation principle of Java program?

Shulou Source: shulou.com Published: 2022-06-02 21:14:18 10月03日 Update

This article mainly introduces "what is the development and operation principle of Java program". In daily operation, I believe that many people have doubts about the development and operation principle of Java program. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "what is the development and operation principle of Java program". Next, please follow the editor to study!

1. Write the source file

The code written is called "source code" or "source code". In general, we save the source code to a text file with the suffix .java, which is called the source file. For convenience, we will keep the file name consistent with the class name (including uppercase and lowercase).

2. Compilation

The source files are written by programmers, and we can easily recognize the meaning of each line of code, but in a computer, CPU can only recognize binary instructions. So, what you need to do now is to convert between the source file and the computer instructions. Because of the structure and characteristics of the Java language, designers first convert the source file into a special binary file, and then give the binary file to the Java runtime environment (JRE) for execution. The process of converting to a binary file is called compilation (which uses the javac command), and the resulting binary file is called a bytecode file (suffixed with .class). If Test.java is compiled, it will generate Test.class. This process is all done automatically by the Java compiler and does not require any special operation by the programmer.

3. Run

The principle of opening and running Java programs is not simply to give bytecode files (.class files) to the operating system to execute, that is because the size, scope and calculation of the data in different operating systems are very different, which will cause the same code to run differently between different systems, which is not what designers want to see.

The designers of Java have come up with a clever idea, which is to write a virtual machine (JVM) that can execute Java programs correctly for different operating systems, and then build this virtual machine into Java's runtime environment (JRE), so that the same piece of Java code can run the same effect on different operating systems. The process of handing the bytecode file (.class) to the Java runtime environment (JRE) is called the run of the Java program (which uses the java command).

At this point, the study on "what is the principle of the development and operation of Java programs" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Run file program principle different binary source file system process development operating system code learning compilation byte environment designer design large special Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Xiaomi Shulou Information MySQL Shulou Tech Info