The method for loading a library in Java is related to its classloader. Different JVMs have different classloader. This section describes the loading sequence of the built-in JVM of j2sdk.
First, Java loads the jar (ZIP, directory) contained in the parameter according to the system parameter classpath. As long as you use this JVM, you do not need to set classpath. Classes used in the program will be automatically found and loaded here.
When we run java.exe to run a program, we can also add the-classpath (-CP) and the package used. However, these packages will only be valid during this operation and will not affect other programs.
Finally, the program loads class files from the current directory (current package. (Nonsense)
Like tomcat, the second method is used to add additional packages. Therefore, there are two ways to add third-party packages in Tomcat. One is to add the system parameter classpath, and the other is to modify the BAT file.