On the difference between Java project and Java Web project importing jar package

The current projects are basically Java Web projects, so there will be problems importing jar packages. Mainly introduce the differences between Java projects and Java Web projects:

Java project:

When the classloader loads jars and classes, they are loaded separately. Generally, there are two types of jar import:

1. It is directly introduced into lib under Web inf

2. Import on user library

Regardless of the above introduction, the jar package can be loaded and run, and the classloader will load intelligently (run locally JRE)

JavaWeb project:

Instead of running through the local JRE, it is deployed to web servers (such as Tomcat and jetty), which implement their own class loaders

Take Tomcat as an example:

1.common CommonClassLoader

2.server CatalinaClassLoader

3.shared SharedClassLoader

4. Webapps webappclassloader (load jar under WEB-INF)

To put it simply, when importing jar packages into a Java Web project, you need to import the jar packages into WEB-INF so that the server can load them. When the project runs, the methods of the project can also be called. It is not allowed to put them into the user library, because they can only be run locally, and the server cannot load them Therefore, there is no problem when calling methods locally, but the server will report that the corresponding jar cannot be found

The difference between Java project and Java Web project in importing jar package is all the content shared by Xiaobian. I hope it can give you a reference and support more programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>