JAR vs WAR
JAR thiab WAR yog ob hom ntaub ntawv khaws cia. Zoo dua, cov ntaub ntawv WAR kuj yog JAR cov ntaub ntawv, tab sis lawv tau siv rau ntau lub hom phiaj. JAR cov ntaub ntawv zoo li cov ntaub ntawv ZIP paub zoo. Lawv tuaj yeem siv rau txhua lub hom phiaj kev khaws cia, tab sis kev siv JAR cov ntaub ntawv nrov tshaj plaws yog siv lawv los ua cov thawv rau Java cov ntaub ntawv hauv chav kawm thiab cov ntaub ntawv muaj peev xwm uas tsim ib daim ntawv thov java. WAR cov ntaub ntawv yog siv tshwj xeeb rau kev xa tawm cov ntawv thov hauv web.
JAR yog dab tsi?
JAR (Java ARchive) yog cov ntaub ntawv khaws cia uas nqa ntau lwm cov ntaub ntawv. JAR cov ntaub ntawv feem ntau yog siv los ntawm Java cov neeg tsim khoom los faib cov ntawv thov Java lossis cov tsev qiv ntawv Java siv cov ntaub ntawv JAR ua cov thawv rau cov ntaub ntawv Java chav kawm thiab cov ntaub ntawv sib xws (i.e. ntawv, suab, video, thiab lwm yam). Paub zoo cov ntaub ntawv archiving hom ZIP yog lub hauv paus ntawm cov ntaub ntawv JAR yog tsim rau. Cov neeg siv tuaj yeem siv lub thawv hais kom ua ntawm JDK (Java Development Kit) lossis ZIP software rau rho tawm cov ntsiab lus ntawm JAR cov ntaub ntawv. JAR cov ntaub ntawv yog ib txoj hauv kev yooj yim heev los rub tawm tag nrho lub vev xaib thov hauv ib cov ntaub ntawv, tsis tas yuav rub tawm tag nrho cov ntaub ntawv uas tsim cov ntawv thov web sib cais. Txhawm rau nyeem / sau JAR cov ntaub ntawv, Java cov neeg tsim khoom siv cov chav kawm uas muaj nyob hauv java.util.zip pob. Yog tias JAR cov ntaub ntawv yuav tsum tau ua tiav raws li daim ntawv thov nyob ib leeg, ces ib qho ntawm cov chav kawm yuav raug teev tias yog chav kawm "tseem ceeb" hauv cov ntawv nkag ntawm cov ntaub ntawv manifest. Executable JAR cov ntaub ntawv tuaj yeem khiav tau siv java hais kom ua nrog lub thawv ntim (piv txwv li java -jar foo.jar).
WAR yog dab tsi?
WAR (Web Application aRchive) yog JAR cov ntaub ntawv siv los ua lub thawv rau ib pab pawg ntawm cov ntaub ntawv thov web (uas ua rau lub vev xaib) xws li JSP (Java Server Pages), servlets, class files, XML cov ntaub ntawv thiab lub vev xaib (HTML) nplooj ntawv. WAR cov ntaub ntawv raug txheeb xyuas los ntawm lawv cov ntaub ntawv.war extension. Lawv tau tsim los ntawm Sun Microsystems (thawj tus tsim tawm ntawm Java programming lus). Cov kos npe digital siv rau ntawm JAR cov ntaub ntawv (kom tso siab rau cov lej) tuaj yeem siv rau ntawm WAR cov ntaub ntawv ib yam.
A WAR cov ntaub ntawv tau teeb tsa sab hauv rau hauv cov hierarchy ntawm cov npe tshwj xeeb. Cov qauv ntawm daim ntawv thov lub vev xaib muaj nyob hauv WAR cov ntaub ntawv tau txhais hauv cov ntaub ntawv web.xml (uas nyob hauv / WEB-INF cov npe). Web.xml kuj piav qhia txog qhov URL txuas nrog lub servlet twg. Lawv kuj txhais cov kev hloov pauv uas nkag tau rau hauv cov khoom siv hluav taws xob thiab cov kev vam meej uas yuav tsum tau teeb tsa. Txawm li cas los xij, yog tias WAR cov ntaub ntawv tsuas muaj JSP cov ntaub ntawv, ces cov ntaub ntawv web.xml yog xaiv tau.
JAR thiab WAR yog dab tsi?
JAR cov ntaub ntawv muaj.jar cov ntaub ntawv txuas ntxiv, thaum WAR cov ntaub ntawv muaj.war extension. Tab sis, cov ntaub ntawv WAR yog hom tshwj xeeb ntawm JAR cov ntaub ntawv. JAR cov ntaub ntawv muaj cov ntaub ntawv hauv chav kawm, tsev qiv ntawv, cov peev txheej thiab cov ntaub ntawv khoom ntiag tug. WAR cov ntaub ntawv muaj servlets, JSP nplooj ntawv, nplooj ntawv HTML, JavaScript coding. JAR cov ntaub ntawv yog siv los khaws tag nrho Java (desktop) daim ntawv thov, thaum WAR cov ntaub ntawv siv los xa cov ntawv thov web.