Home >Java >javaTutorial >What is the interpreter of java
The Java interpreter is part of the JVM. The Java interpreter is used to interpret and execute programs compiled by the Java compiler. java.exe can simply be thought of as a Java interpreter.
The role of the java interpreter
When compiling a .java file, we will get an output file with the exact same name; but for each file in the .java file Classes, they all have a .class extension. Therefore, we may end up with a large number of .class files from a small number of .java files. If you have written programs in an assembly language before, you may be used to the compiler first splitting out a transitional form (usually an .obj file), and then using a linker to encapsulate it with other things (generating a executable file), or packaged with a library (generating a library). But that's not how Java works. A valid program is a series of .class files that can be encapsulated and compressed into a JAR file (using the jar tool provided by Java 1.1). The Java interpreter is responsible for finding, loading and interpreting these files.
The running process of the java interpreter:
First find out the environment variable CLASSPATH configured when installing the JDK before. JDK after 1.8.0 will automatically configure environment variables.
CLASSPATH contains one or more directories that are used as the root directory for finding .class files. Starting from the root directory, the interpreter takes the name of the package and replaces each period (.) with a backslash (\) to produce a pathname from the CLASSPATH root (aa.bb.cc becomes aa\bb\cc or aa/bb/cc or other, depending on the OS).
The obtained path will be connected to various items in CLASSPATH. The interpreter will store the .class file related to the class name you want to create in these directories.
The above is the detailed content of What is the interpreter of java. For more information, please follow other related articles on the PHP Chinese website!