Search
Duplicate
๐ŸŽจ

Jar vs War

Jar

โ€ข
ํŒจํ‚ค์ง€ ํŒŒ์ผ ํฌ๋งท์ด๋‹ค.
โ€ข
jar ํ™•์žฅ์ž๋ฅผ ๊ฐ€์ง„๋‹ค.
โ€ข
library, resource, metadata file ๋“ค์„ ๊ฐ€์ง„๋‹ค.
โ€ข
์••์ถ•๋œ class ํŒŒ์ผ๊ณผ ์ปดํŒŒ์ผ๋œ java library ์™€ application ์ž์›๋“ค์„ ํฌํ•จํ•œ๋‹ค.
META-INF/ MANIFEST.MF com/ eden/ MyApplication.class
Shell
๋ณต์‚ฌ
โ€ข
MANIFEST.MF
โ—ฆ
์•„์นด์ด๋ธŒ์— ์ €์žฅ๋œ ํŒŒ์ผ๋“ค์— ๋Œ€ํ•œ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ํฌํ•จํ•œ๋‹ค.
โ€ข
jar ๋‚˜ ๋นŒ๋“œ ํˆด(Maven, Gradle) ๋กœ Jar ํŒŒ์ผ ์ƒ์„ฑ ๊ฐ€๋Šฅ

War

โ€ข
Web Application Archive
โ€ข
Servlet, JSP ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์žˆ๋Š” ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํŒจํ‚ค์ง•ํ•  ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค.
META-INF/ MANIFEST.MF WEB-INF/ web.xml jsp/ helloWorld.jsp classes/ static/ templates/ application.properties lib/ // *.jar files as libs
Shell
๋ณต์‚ฌ
โ€ข
WEB-INF ์—๋Š” html, js ๋“ฑ๊ณผ ๊ฐ™์€ ์ •์  ํŒŒ์ผ๊ณผ servlet class, web.xml ๋“ฑ๊ณผ ๊ฐ™์€ ํŒŒ์ผ๋„ ์žˆ๋‹ค.

์ฐจ์ด

JAR files allow us to package multiple files in order to use it as a library, plugin, or any kind of application. On the other hand, WAR files are used only for web applications.
The structure of the archives is also different.ย We can create a JAR with any desired structure. In contrast, WAR has a predefined structure withย WEB-INFย andย META-INFย directories.
Finally, we canย run a JAR from the command lineย if we build it as anย executable JARย without using additional software. Or, we can use it as a library. In contrast, weย need a server to execute a WAR.