VarunKrish

Build and Deploy WAR file using Java alone

Today I needed to test a bunch of code which is given here

The article talks about using Dojo and JSON for AJAX applications.

There is a sample application available on the site for the article.Its a zip file when extracted

has the following structure.

Now i need to build a WAR ( Web Archive ) for deployment on my container – Tomcat.

so i goto to the windows commandline.

c:\cd dojo_json_samplewebapp

c:\cd web

Now in the web directory I type the following command.

C:\dojo_json_sampleapp\web>jar cvf dojo.war *

If the operation is working you will get he list of messages similar to this one show below
added manifest
adding: actions/(in = 0) (out= 0)(stored 0%)
adding: actions/authors.jsp(in = 6426) (out= 2513)(deflated 60%)
adding: actions/book.jsp(in = 455) (out= 254)(deflated 44%)
adding: actions/welcome.jsp(in = 219) (out= 146)(deflated 33%)
adding: example1.jsp(in = 948) (out= 433)(deflated 54%)
adding: example2.jsp(in = 1775) (out= 786)(deflated 55%)
adding: example3.jsp(in = 1132) (out= 548)(deflated 51%)
adding: index.jsp(in = 286) (out= 162)(deflated 43%)
adding: js/(in = 0) (out= 0)(stored 0%)
adding: js/dojo/(in = 0) (out= 0)(stored 0%)
adding: js/dojo/dojo.js(in = 169107) (out= 43860)(deflated 74%)
adding: js/dojo/utils/(in = 0) (out= 0)(stored 0%)
adding: js/dojo/utils/AutoComplete.js(in = 6472) (out= 1796)(deflated 72%)
adding: js/dojo/utils/templates/(in = 0) (out= 0)(stored 0%)
adding: js/dojo/utils/templates/AutoComplete.html(in = 87) (out= 72)(deflated 17
%)
adding: WEB-INF/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/classes/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/classes/com/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/classes/com/esolaria/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/classes/com/esolaria/dojoex/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/classes/com/esolaria/dojoex/Book.class(in = 1083) (out= 539)(def
lated 50%)
adding: WEB-INF/classes/com/esolaria/dojoex/BookManager.class(in = 1194) (out= 7
34)(deflated 38%)
adding: WEB-INF/classes/org/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/classes/org/json/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/classes/org/json/CDL.class(in = 2751) (out= 1214)(deflated 55%)
adding: WEB-INF/classes/org/json/Cookie.class(in = 2094) (out= 1153)(deflated 44
%)
adding: WEB-INF/classes/org/json/CookieList.class(in = 1269) (out= 657)(deflated
48%)
adding: WEB-INF/classes/org/json/HTTP.class(in = 1844) (out= 972)(deflated 47%)
adding: WEB-INF/classes/org/json/HTTPTokener.class(in = 662) (out= 435)(deflated
34%)
adding: WEB-INF/classes/org/json/JSONArray.class(in = 5761) (out= 2522)(deflated
56%)
adding: WEB-INF/classes/org/json/JSONException.class(in = 159) (out= 132)(deflat
ed 16%)
adding: WEB-INF/classes/org/json/JSONObject$1.class(in = 160) (out= 128)(deflate
d 20%)
adding: WEB-INF/classes/org/json/JSONObject$Null.class(in = 511) (out= 303)(defl
ated 40%)
adding: WEB-INF/classes/org/json/JSONObject.class(in = 8149) (out= 3677)(deflate
d 54%)
adding: WEB-INF/classes/org/json/JSONStringer.class(in = 2848) (out= 1339)(defla
ted 52%)
adding: WEB-INF/classes/org/json/JSONTokener.class(in = 3619) (out= 1942)(deflat
ed 46%)
adding: WEB-INF/classes/org/json/Test.class(in = 12730) (out= 5719)(deflated 55%
)
adding: WEB-INF/classes/org/json/XML.class(in = 3758) (out= 1934)(deflated 48%)
adding: WEB-INF/classes/org/json/XMLTokener.class(in = 2932) (out= 1518)(deflate
d 48%)
adding: WEB-INF/lib/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/web.xml(in = 204) (out= 174)(deflated 14%)
adding: welcome.jsp.html(in = 195) (out= 143)(deflated 26%)

Now goto Tomcat and deploy the WAR file.

The WAR file will be generated inside the web folder as in my case.

i can access the app using the URL http://localhost:8080/dojo/ once its deployed

Exit mobile version