Java loading class library

xiaoxiao2021-03-06  94

The Java adds the library to its ClassLoader, different JVMs have different ClassLoaders. The JVM's loading order of JVM comes with the J2SDK is now introduced.

First, Java will follow the system's parameter classpath, load the JAR (ZIP, directory) included in the parameter. Just use the JVM, you don't have to set ClassPath, you will automatically find and load this in the program.

Second, when we run a program in Java.exe, you can also add -classpath (-CP) to add the package used. However, these packages are only valid for this operation, and there is no impact on other programs.

Finally, the program will also load the class file from the current directory (current package). (Nonsense)

The Tomcat is used in the second one to add additional packages. So there are two ways to make the third party's package in Tomcat to add these packages. One is plus in the system's parameter classpath, and another method is to modify the BAT file.

转载请注明原文地址:https://www.9cbs.com/read-96563.html

New Post(0)