In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to understand the operating mechanism of Java language". In daily operation, I believe many people have doubts about how to understand the operating mechanism of Java language. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to understand the operating mechanism of Java language". Next, please follow the editor to study!
One: the operation mechanism of high-level language
Computers cannot directly understand high-level languages, but can only understand machine languages (such as assembly), so high-level languages must be translated into machine languages before computers can execute programs written in high-level languages. There are two ways of translation: compilation and interpretation.
1. Compiled language (e. G., CMagna Category +)
Using a special compiler, for a specific platform (operating system), the source code of a high-level language is "translated" at once into machine code (including machine instructions and operands) that can be executed by the hardware of the platform. and packaged into the format of executable programs recognized by the platform. Advantages: high running efficiency, disadvantages: compiled programs are not portable
two。 Interpretive language (such as Ruby,Python)
A language in which the source program is interpreted line by line into platform-specific machine code and executed immediately using a special interpreter. Interpretive languages usually do not compile and link as a whole. Interpretive languages are equivalent to mixing the compilation and interpretation processes in compiled languages at the same time.
Advantages: cross-platform is easy, disadvantages: low efficiency, can not run independently from the interpreter.
Second: the running mechanism of Java language
1.Java is a combination of compiled and interpreted languages
a. Firstly, the general java compiler is used to compile the java source program into a platform-independent bytecode file (class file).
b. Interpretation and execution of bytecode files by java virtual machine (JVM)
Java bytecode is platform independent and can be run in different system platforms, but different versions of java virtual machines are required, and javajava virtual machines of different system platforms are different.
2.Java Virtual Machine (JVM)
A.JVM is the engine of Java bytecode execution, which not only provides necessary support for the execution of Java programs, but also optimizes Java bytecode to convert it into more efficient machine instructions. Programs are eventually executed on JVM, and class loading in JVM is implemented by the class loader (ClassLoader) and its subclasses.
B.ClassLoader is an important system component of the Java runtime, which is responsible for finding and loading classes of class files at run time.
C.JVM shields the information related to the specific operating system platform, so that Java programs only need to generate bytecode files (class files) running on JVM to run on a variety of platforms. Different platforms correspond to different JVM. When executing bytecode, JMV is responsible for sending each bytecode to be executed to the interpreter, and the interpreter translates it into machine instructions in a specific platform environment and executes it. The most important feature of Java language is to run across platforms. The purpose of using JVM is to support operating system independent and cross-platform operation.
3.ClassLoader
Part of the a.JVM implementation, including bootstrapcalssloader (boot classloader)
The API of the family Java core of the b.ClassLoader family when JVM runs: ExtClassLoader loads the extension API of Java, that is, the lib/ext class; the class in the CLASSPATH settings directory on the AppClassLoader load machine
C.ClassLoader loading process: when running a program, JVM starts, runs bootstrapclassloader, and the ClassLoader loads the java core API, then calls ExtClassLoader to load the extended API, and finally AppClassLoader loads the Class defined in the CLASSPATH directory.
4.JRE
JRE is a JavaRuntimeEnvironment,java runtime environment, which is a necessary set of environments for java programs to run. It is mainly composed of java virtual machines, java platform core classes and several supporting files. It does not include development tools, compilers, debuggers, and other tools.
When executing a java program, the operating system looks for the JRE environment in the following order.
a. First check whether there is JRE in the current directory.
b. Then find out if there is JRE in the parent directory
c. Then look for JRE in the path set by the environment variable PATH
d. Registry to see which JRE the key value of CurrentVersion points to
The basic class libraries that come with JRE are mainly in the JRE\ LIB\ rt.jar file. When the program is running, ClassLoader (class loader) is responsible for finding and loading the base class library and other class libraries referenced by the program. For the basic class library, Classloader automatically goes to the location of rt.jar; for other class libraries, ClassLoader searches in the path set by the environment variable CLASSPATH
5.JDK
A.JDK is Java Development Kit, or java development kit for short.
B.JDK is the core of java. It includes the java runtime environment, a bunch of java toolbox java-based class libraries (rt.jar).
C.JDK contains not only the full contents of JRE, but also the tools that developers use to compile, debug and run java programs.
There is an inclusive relationship among d.JDK, JRE and JVM. The range from large to small is JDK, JRE, JVM.
At this point, the study of "how to understand the operating mechanism of the Java language" is over. I hope to be able to solve your 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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.