When setting JDK environment variables, what are Rt. jar, DT. jar, and tool. jar in Lib, and what are their functions?

Source: Internet
Author: User

After searching for a long time on the Internet, it is a bit confusing. This is the DT in the JDK configuration classpath. jar and tools. what are the two jar files? Some people say this DT. jar is about swing. Open this package and you can see the classes related to swing. If swing is used, configure the classpath, but RT. what about swing in jar? Isn't it actually including the swing class library? There is also whether the two packages are used as the development class libraries, or the class libraries required for the javac program running in JDK. If we do not path the two packages, what is the impact on our programs?

------------------------------------------------------

A: DT. jar and tools. jar is the most basic java package, which includes from the most important lang Package of Java to various advanced functions such as Visual swing package. It is essential for Java.
The bin in path contains Java executable compilers and tools, such as Java and javadoc. You can run CMD in any folder and type javac, the system can automatically call the Java compiler because of the setting of this environment variable.

Rt. jar is a Java base class library, DT. jar is a class library about the runtime environment, and tools. jar is a tool class library.

Set in classpath to allow you to import *
---------------------------------------------------------------

Tool. jar is used in the web system.

You can use WinRAR to check what is in it.
---------------------------------------------------------------

1.
Rt. jar is stored in the claspath of the root classloader by default.
You can remove Rt. jar from classpath.

Then, run a simple class in Java-verbose xxxx to know the path of the JVM system root loader.

Not only does Rt. Jar JRE/lib contain most of the jar files in this path

2.

Tools. jar is used by the system to compile a class, that is, javac.

Javac XXX. Java

It is actually running

Java-calsspath = % java_home %/lib/tools. Jar XX. XXX. Main XXX. Java

Javac encapsulates the above command, so tools. jar does not need to be added to classpath.

3.
DT. jar is a class library about the running environment. It is mainly about the swing package. It is best to add

DT. jar seems to be some swing classes, and the default JRE In the eclipse development environment does not include it. It should be useless.
The tools. Jar application server is used to compile JSP files. The application server loads the files by itself and does not need to be set by itself.

Description of path and classpath:
1. the PATH variable indicates that the system can recognize Java and javac commands in any path.
2. the classpath variable indicates the path in which the class to be used or executed by the JVM is stored, so that the JVM can easily load the class file ,.; indicates the current path, tools. jar and DT. jar is the path of the class library. If you do not need anything in swing, do not add DT. jar. Tools. jar is the most basic tool class, such as javac, which cannot be developed without being added.

1. rt. jar is put in claspath in the loading path of the root classloader by default. You can remove RT in classpath. jar and then run a simple class using Java-verbose ** X to know that the path of the JVM system root loader is not just RT. most jar files under jar JRE/lib are in this path.
2. tools. jar is used by the system to compile a class, that is, javac is used for javac **. java is actually running Java-calsspath = % java_home %/lib/tools. jar xx. **. main **. java javac is the encapsulation of the above command, so tools. jar does not need to be added to classpath.
3. dt. jar is a class library about the runtime environment. It is mainly about the swing package. It is best to add


DT. jar is a class library about the runtime environment, mainly a swing package.
Tools. jar is a class library for some tools.
Rt. jar contains the JDK base class library, which is the class file of all classes you see in Java Doc.

The classes in toos. jar are required for compiling and running, respectively
Sun. Tools. java .*;
Sun. Tools. javac .*;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.