JDK and JRE, the difference between the CLASSPATH and PATH (rpm)

Reproduced to take notes, provenance https://www.cnblogs.com/newbie27/p/10411623.html

First, the difference between the JRE and JDK

1, the role of the JDK, each file directory:

  • bin directory: to store some terminal JDK command tool for development. Common tools such as: the role of "javac" is to compile the java source files into class files (ie word decode the file); the role of "java" command is to run the class file.
  • db directory: is an open source relational database java development;
  • Contents include: is the first document of some C language;
  • jre directory: JDK depends java runtime;
  • lib directory: store some libraries JDK development tools rely on;
  • man directory: store the JDK development tools documentation.

2, the difference between the JRE and JDK

  • JDK java development is the core component, the core component is used to explain the java program compiler, including java compile (javac) facing the java developer.
  • JRE is a java runtime environment to support java programs run mainly contains the JVM, for the java program. Java is a cross-platform language, a compiler, run multiple times on multiple computers, such mechanisms rely mainly on the JVM implementation. java program is compiled from the intermediate byte code, the intermediate byte code can not be run directly to the machine, the JVM must go through an intermediate byte code into machine language.
  • When you configure the environment variable in the development process, PATH and CLASSPATH configurations are for JDK can be configured as follows:
JAVA_HOME=“JDK安装的根目录"
PATH=“.;%JAVA_HOME%/bin"
CLASSPATH=".;%JAVA_HOME%/lib/tools.jar;%JAVA_HOME%/lib/dt.jar"

 

Second, the difference between PATH and the CLASSPATH

  • PATH is the operating system of all executables path;
  • Meaning jvm classpath variable is to tell the class to use or execute on what path, easy to load JVM class files,
  • path is the system used to specify the full path to the executable file, even if the path is not set the JDK path is also executable Java files, but you must write out the full path, such as C: \ Java \ jdk1.7 \ bin \ javac HelloWorld .java. executable file path is used to route search is performed, the executable file is not performed if the current directory, it will in turn set the search path path; java various operations and commands are installed in the path bin directory. So set the JDK installation directory in the path after then do not write the full path to java file out, it will automatically go to the path set in the path to find;
  • classpath is where you specify the location of the files used in the program classes (.class), just as at the time of the introduction of a class: import javax.swing.JTable This sentence tells the compiler to be introduced under this package javax.swing JTable class, classpath tells the compiler where to look to this category (provided that you set the path of this class in the classpath). If you want to compile looking in the current directory, add, such as ".":;. C: \ Java \ jdk1.7 \, so the compiler to the current directory and C: \ Java \ jdk1.7 \ find javax.swing.JTable this class; also mention the next: most people write programs using Eclipse, no classpath does not matter, because Eclipse has associated configuration;

Third, the effect of the CLASSPATH and configured tools.jar of dt.jar

Role 1, tools.jar, dt.jar of

  • tools.jar is JDK class library on a number of tools that we used with the program base class library (java. *, javax. *) does not matter. tools.jar primarily for jdk tools, including javac, java, javadoc, javap and other tools to provide the use to the library. Open tools.jar compression software, you will find that there are many files and exe tool in the bin directory of relativity, as shown below: (javap: abbreviation java printer is jdk that comes with a decompiler)

  • dt.jar is DesignTime abbreviation Archive, first look at the definition of dt.jar of SUN: Also includes dt.jar, the DesignTime archive of BeanInfo files that tell interactive development environments (IDE's) how to display the Java components and how to let the developer customize them for the application. In fact dt.jar which is mainly BeanInfo swing components. Based on these IDE BeanInfo show how these components as well as developers to customize them.

2 difference, tools.jar and foundation class library

  • When you configure the environment variables, you will find JAVA_HOME, PATH, CLASSPATH three variables there were no basic class library (refers to all of Java. * At the beginning of class) and extensive class library (such as javax. * At the beginning of class), that is, we import those programs jar package stuff is located.
  • The reason is: CLASSPATH of these classes are the Application ClassLoader or our custom class loader to load, where the library comprises a base course, can not, then if the class library includes a base, and with two different custom class loader to load the base class, the base class that it gets not only, so they can not guarantee the security of Java classes.
  • In fact, these libraries are based on% JAVA_HOME% \ jre \ lib directory (e.g., wherein the rt.jar, resource.jar), class loading mechanism is also mentioned in an article, under the category of the directory (in the jar package ) will be automatically loaded by the Bootstrap ClassLoader, and to ensure the model foundation class library will be loaded by the Bootstrap ClassLoader parent delegation, which also ensures the uniqueness of the base class.
  • In addition, extensive class library in% JAVA_HOME% \ jre \ lib under \ ext directory, type in the directory by Extension ClassLoader to load, and sometimes we have to import it inside the class, but did not use the base class library frequently. Similarly, Extension ClassLoader automatically to the directory to find extension class, without the need for us to specify.
Published 52 original articles · won praise 7 · views 10000 +

Guess you like

Origin blog.csdn.net/YKWNDY/article/details/103493033