First, we need to introduce the functions of the following parameters:
Current Directory (current directory ):
The currently used directory is the current directory. For example, when you open notepad and are running, the current directory is C:/Windows. If you use the CMD command to open the command line window, the current directory is C: /Windows/system32.pdf if you are using the Java command, set java.exe in the bin as the default directory.
When configuring environment variables in Java development, the system default path (when classpath is not set) is also the current directory.
It refers to the JDK installation directory, such as D:/j2sdk1.4.2 _ 16.
You can create a java_home variable with a value of D:/j2sdk1.4.2 _ 16.
Why do I need to set it? Can I not set it? If this parameter is not set, it can be dropped, but it is best to set it.
Now, when it is a variable for java_home = D:/j2sdk1.4.2 _ 16, it is to avoid writing more. Another benefit is that when we need to change a JDK, you only need to change the value of java_home. After reading the startup Analysis of Tomcat, you will understand it.
% Java_home % is used to represent D:/j2sdk1.4.2 _ 16 When referencing it in the environment variable.
The system variable path tells the operating system executable file (*. EXE ,*. bat, etc.) path, when the OS (operating system) discovers *. in EXE, Windows searches for the command from the current directory by default. If no command is found, the OS searches for the command in the path set by path and then runs the command.
System Default System variables: Path = % SystemRoot %; % SystemRoot %/system32; % SystemRoot %/system32/WBEM
That is to say, it is in the preceding three directories (multiple variables are separated by semicolons *. EXE file, which can be executed anywhere (commands that can be directly executed in the running window, such as cmd and notepad, are basically in the three directories above ), so they can run it directly.
What does the above % SystemRoot % mean? % SystemRoot % is the default installation path of the operating system.
If your Windows XP is installed in C:/Windows
Then your % SystemRoot % PATH is C:/Windows
% SystemRoot % is only a symbol, representing your system installation directory
The following is the default installation path for common systems:
98 ---- C:/Windows
2000 -- C:/winnt
2003 -- C:/Windows
XP ---- C:/Windows
When we are going to develop Java, osscloud often uses java.exe‑javac.exe and so on (if JDK is installed on D:/j2sdk1.4.2 _ 16), we should set D:/j2sdk1.4.2 _ 16/bin (% java_home %/bin) add it to the system path.
Note: If the position you add is not at the end, add a semicolon (% java_home %/bin) to the bin. Separate multiple variables with semicolons, if not, add one.
Clearly: the path % java_home %/JRE/bin does not need to be added to the path. Reference: http://java.sun.com/javase/6/docs/technotes/tools/windows/jdkfiles.html
Classpath is dedicated to Java, which is equivalent to the path of windows; Path is for the entire windows.
Classpath tells the Java Virtual Machine (JVM) where the *. Class file to be used or executed is stored.
The so-called JVM is like activating another OS on Microsoft OS. For JVM, classpath is like a path for Microsoft OS. Therefore, you need to set classpath to run the program on JVM, however, like Windows, JVM also has a default path for searching class files. For those who are learning Java at the beginning, the default path is enough for us, that is, the current path, therefore, classpath is optional.
In Windows, classpath is case-insensitive, and the names of other environment variables are the same.
The class path is the path that the Java Runtime Environment searches for classes and other resource files. the Class search path (more commonly known by the shorter name, "class path") can be set using either the-classpath option when calling a JDK tool (the preferred method) or by setting the classpath environment variable. the-classpath option is preferred because you can set it individually for each application without affecting other applications and without other applications modifying its value.
If you use other resource files in classpath, it means you are familiar with classpath and you can set it on your own.
The default class path is the current directory. setting the classpath variable or using the-classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include ". "in the new settings. ----- when classpath is not set, the default classpath is the current directory. If you want to set classpath, you must add ". ", the vertices in the English state represent the current directory.
Do you want to add other paths (including file directories and package root directories) to classpath? This depends on the development needs. Generally, we cannot use them for beginners.
There is no doubt about the path settings, but the classpath is confused. Should Rt. jar, DT. jar, and tool. Jar be added in the path?
It is certain that RT. jar is not required and JDK will automatically load it. You can use the Java-verbose command to view details.
Let's take a look at the tools. jar and DT. Jar under % java_home %/lib:
Do you need to add classpath to tools. jar and DT. jar? I have checked some materials. In Sun JDK 1.2 and later versions, it contains a group of APIs that can compile and execute Java code at runtime. These APIs are included in the tools. Jar class library. This function allows Java programs to dynamically compile and execute Small code blocks during runtime. In some cases, this function makes the Java application architecture more flexible and open. There is another example that I don't understand very well, so I won't post it.
If you do not understand what dynamic compilation is or do you need to "dynamically compile Java programs", you do not need it. The system sets it by default. You have also set it by default.
The dt. jar package does not need to be imported after jdk1.4.0 and will be automatically imported at runtime. This is a safe and reliable answer I chose after collecting n documents.
To put it short, I will not analyze Tomcat startup. I will tell you how to set it up. Before Tomcat 4, Tomcat 4 used tomcat_home to represent the tomcat installation directory, and tomcat _base was used in the middle, after Tomcat 4, a new servlet container Catalina is used, so the environment variable name is changed to catalina_home. Therefore, you do not need to set all the three variables when setting them, catalina_home is enough. If you have installed the decompressed version, you do not need to set catalina_home. Double-click STARTUP. bat in the bin and shut down. bat.
In summary: (in winxp) set the environment variables in the JDK installation directory to-D:/j2sdk1.4.2 _ 16 and tomcat installation directory to-D:/apachetomcat/Apache-Tomcat-6.0.14 as follows: you can also refer to the http://java.sun.com/javase/6/docs/technotes/tools/windows/jdkfiles.html to decide which ones are needed.
Java_home = D:/j2sdk1.4.2 _ 16
Add at the beginning of the PATH environment variable (if the system is not created before) % java_home %/bin; (add at the beginning to increase the search speed)
Classpath =. This step does not need to be set.
Catalina_home = D:/apachetomcat/Apache-Tomcat-6.0.14. (Decompressed Version)