In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to run the war package". In the daily operation, I believe many people have doubts about how to run the war package. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to run the war package". Next, please follow the editor to study!
What is a jar package?
The full name of the jar package is Java Archive, and the Chinese name is java Archive File, which is a platform-independent file format that allows many files to be combined into a compressed file (yes, the jar package is a compressed file, and even the word jar means a jar. In fact, the jar package also uses zip compression, but the file suffix is defined as jar). JavaSE programs can be packaged as jar packages.
Although jar packages are compressed and released using zip, unlike zip compression, jar files can also be used to deploy and package libraries, components and plug-ins, and such jar packages can be directly used by compilers and JVM.
To put it simply, zip only compresses the code files, and jar packages not only compress the files, but also package the classes in the code, so that others can directly introduce and invoke them.
What is a war package?
The war package is very similar to the jar package, but the war package is usually used for websites, and it is a web module that can be run directly. When we develop a web project, we usually use a webapp folder for development. This folder can be placed directly under the Tomcat webapps folder to start the project. And the war package is to package this folder.
War package is a web application format proposed by Sun. Similar to jar, it is a compressed package for many files. The files in the war package are organized according to a directory structure.
Generally, the root directory contains html and jsp files, or directories containing these two files, as well as the WEB-INF directory. There is usually a web.xml file and a classes directory in the WEB-INF directory. Web.xml is the configuration file for this application, while the classes directory contains compiled servlet classes and jsp, or other classes that servlet depends on (such as JavaBean). Usually these dependent classes can also be packaged as jar packages and placed in the lib directory under WEB-INF.
Difference
The purpose of using jar files is to encapsulate classes and related resources in a compressed archive file for easy invocation. For war files, a war file is a Web application. It contains Servlet, HTML pages, Java classes, image files, and other resources that make up the Web application, not just the archives of the classes.
To put it simply, jar is just an archive of classes, while the war package is a complete web application.
How to pack a war bag
The packaging of war packages is also achieved through the jar command. You can pack it with the following command
Jar cvf d:/test/myweb2.war.
Where cvf is a command parameter, which means to generate a document, show the generation process, and specify the name of the generated file.
D:/test/myweb2.war is the storage path and file name of the generated document.
The last period indicates that you want to package everything in the current directory.
You can also package war using some development tools, such as maven projects, which can be packaged with maven. If ant is used in your project, you can also use ant to export and deploy war packages. Similar tools also have gradle and so on, the editor will not introduce them one by one.
Using IDE generally provides packaging tools that can simply pack a war package (follow the W3C technical headlines, subsequent articles will teach you how to use idea and eclipse to pack war packages).
How to deploy the war package
The deployment of the war package is quite simple, just put the war package in the webapps folder of Tomcat, start Tomcat, and it will unpack and run the corresponding web project itself.
At this point, the study on "how to run the war package" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.