{"id":1555,"date":"2015-03-06T21:18:07","date_gmt":"2015-03-06T20:18:07","guid":{"rendered":"http:\/\/codingexplained.com\/?p=1555"},"modified":"2015-03-07T15:23:17","modified_gmt":"2015-03-07T14:23:17","slug":"unpacking-war-file-os-x-and-linux","status":"publish","type":"post","link":"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux","title":{"rendered":"Unpacking War File on OS X and Linux"},"content":{"rendered":"<p>If you have packaged a web application within a <span class=\"code\">.war<\/span> file, then you might want to check the contents of it for various reasons. There are a number of tools that can do this, but I am going to show you a simple command that can display the contents of the war file within the Terminal. Therefore one does not need to install any software to do this. Another command can extract the contents of the war file, which I will also show you. Please note that these commands work for UNIX-like systems such as Linux or Mac OS X. I am sure it can also be used on Windows, but I have no set it up nor tested it myself.<\/p>\n<h2>Show Contents of War File<\/h2>\n<p>First, let us see how we can display the contents of a war archive within the Terminal. It is as simple as the below command.<\/p>\n<pre>\r\n<code>\r\njar -tf example.war\r\n<\/code>\r\n<\/pre>\n<h2>Extract Contents of War File<\/h2>\n<p>Now, let us extract the contents of the war archive.<\/p>\n<pre>\r\n<code>\r\njar -xvf example.war\r\n<\/code>\r\n<\/pre>\n<p>This extracts the contents of the file in the current directory, which may not be desirable. Therefore one may want to extract it in a different directory. First, let us create a temporary directory.<\/p>\n<pre>\r\n<code>\r\nmkdir \/tmp\/extracted\r\n<\/code>\r\n<\/pre>\n<p>The following commands copies the war file to the temporary directory, extracts it, removes the war file and lists the contents of the directory.<\/p>\n<pre>\r\n<code>\r\ncd \/tmp\/extracted &amp;&amp; cp \/path\/to\/example.war \/tmp\/extracted\/example.war &amp;&amp; jar -xvf example.war &amp;&amp; rm example.war &amp;&amp; ls -al\r\n<!--formatted--><\/code>\r\n<\/pre>\n<p>I hope this helped you. Thank you for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have packaged a web application within a .war file, then you might want to check the contents of it for various reasons. There are a number of tools that can do this, but I am going to show you a simple command that can display the contents of the war file within the&hellip; <a href=\"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux\" class=\"more-link\">read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[8],"tags":[42,112,111,82,113],"series":[],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Unpacking War File on OS X and Linux<\/title>\n<meta name=\"description\" content=\"Unpacking .war files on UNIX-like systems such as OS X or Linux is easy. No third party software is needed, as this can be done within the Terminal.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unpacking War File on OS X and Linux\" \/>\n<meta property=\"og:description\" content=\"Unpacking .war files on UNIX-like systems such as OS X or Linux is easy. No third party software is needed, as this can be done within the Terminal.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux\" \/>\n<meta property=\"og:site_name\" content=\"Coding Explained\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codingexplained\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codingexplained\" \/>\n<meta property=\"article:published_time\" content=\"2015-03-06T20:18:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-03-07T14:23:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codingexplained.com\/wp-content\/uploads\/2015\/11\/codingexplained-fb-promote.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"444\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Bo Andersen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codingexplained\" \/>\n<meta name=\"twitter:site\" content=\"@codingexplained\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bo Andersen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux\",\"url\":\"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux\",\"name\":\"Unpacking War File on OS X and Linux\",\"isPartOf\":{\"@id\":\"https:\/\/codingexplained.com\/#website\"},\"datePublished\":\"2015-03-06T20:18:07+00:00\",\"dateModified\":\"2015-03-07T14:23:17+00:00\",\"author\":{\"@id\":\"https:\/\/codingexplained.com\/#\/schema\/person\/e19c92ec991f571605f047cefeaa950d\"},\"description\":\"Unpacking .war files on UNIX-like systems such as OS X or Linux is easy. No third party software is needed, as this can be done within the Terminal.\",\"breadcrumb\":{\"@id\":\"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/codingexplained.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unpacking War File on OS X and Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codingexplained.com\/#website\",\"url\":\"https:\/\/codingexplained.com\/\",\"name\":\"Coding Explained\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codingexplained.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/codingexplained.com\/#\/schema\/person\/e19c92ec991f571605f047cefeaa950d\",\"name\":\"Bo Andersen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codingexplained.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/28f5826f9d5d544b0c5e1ec321dfdfb8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/28f5826f9d5d544b0c5e1ec321dfdfb8?s=96&d=mm&r=g\",\"caption\":\"Bo Andersen\"},\"description\":\"I am a back-end web developer with a passion for open source technologies. I have been a PHP developer for many years, and also have experience with Java and Spring Framework. I currently work full time as a lead developer. Apart from that, I also spend time on making online courses, so be sure to check those out!\",\"sameAs\":[\"https:\/\/codingexplained.com\",\"https:\/\/www.facebook.com\/codingexplained\",\"https:\/\/www.linkedin.com\/in\/ba0708\",\"https:\/\/twitter.com\/codingexplained\",\"https:\/\/www.youtube.com\/c\/codingexplained\"],\"url\":\"https:\/\/codingexplained.com\/author\/andy\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Unpacking War File on OS X and Linux","description":"Unpacking .war files on UNIX-like systems such as OS X or Linux is easy. No third party software is needed, as this can be done within the Terminal.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux","og_locale":"en_US","og_type":"article","og_title":"Unpacking War File on OS X and Linux","og_description":"Unpacking .war files on UNIX-like systems such as OS X or Linux is easy. No third party software is needed, as this can be done within the Terminal.","og_url":"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux","og_site_name":"Coding Explained","article_publisher":"https:\/\/www.facebook.com\/codingexplained","article_author":"https:\/\/www.facebook.com\/codingexplained","article_published_time":"2015-03-06T20:18:07+00:00","article_modified_time":"2015-03-07T14:23:17+00:00","og_image":[{"width":1200,"height":444,"url":"https:\/\/codingexplained.com\/wp-content\/uploads\/2015\/11\/codingexplained-fb-promote.png","type":"image\/png"}],"author":"Bo Andersen","twitter_card":"summary_large_image","twitter_creator":"@codingexplained","twitter_site":"@codingexplained","twitter_misc":{"Written by":"Bo Andersen","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux","url":"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux","name":"Unpacking War File on OS X and Linux","isPartOf":{"@id":"https:\/\/codingexplained.com\/#website"},"datePublished":"2015-03-06T20:18:07+00:00","dateModified":"2015-03-07T14:23:17+00:00","author":{"@id":"https:\/\/codingexplained.com\/#\/schema\/person\/e19c92ec991f571605f047cefeaa950d"},"description":"Unpacking .war files on UNIX-like systems such as OS X or Linux is easy. No third party software is needed, as this can be done within the Terminal.","breadcrumb":{"@id":"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/codingexplained.com\/coding\/java\/unpacking-war-file-os-x-and-linux#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codingexplained.com\/"},{"@type":"ListItem","position":2,"name":"Unpacking War File on OS X and Linux"}]},{"@type":"WebSite","@id":"https:\/\/codingexplained.com\/#website","url":"https:\/\/codingexplained.com\/","name":"Coding Explained","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codingexplained.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/codingexplained.com\/#\/schema\/person\/e19c92ec991f571605f047cefeaa950d","name":"Bo Andersen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codingexplained.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/28f5826f9d5d544b0c5e1ec321dfdfb8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/28f5826f9d5d544b0c5e1ec321dfdfb8?s=96&d=mm&r=g","caption":"Bo Andersen"},"description":"I am a back-end web developer with a passion for open source technologies. I have been a PHP developer for many years, and also have experience with Java and Spring Framework. I currently work full time as a lead developer. Apart from that, I also spend time on making online courses, so be sure to check those out!","sameAs":["https:\/\/codingexplained.com","https:\/\/www.facebook.com\/codingexplained","https:\/\/www.linkedin.com\/in\/ba0708","https:\/\/twitter.com\/codingexplained","https:\/\/www.youtube.com\/c\/codingexplained"],"url":"https:\/\/codingexplained.com\/author\/andy"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3mJkW-p5","_links":{"self":[{"href":"https:\/\/codingexplained.com\/wp-json\/wp\/v2\/posts\/1555"}],"collection":[{"href":"https:\/\/codingexplained.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codingexplained.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codingexplained.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codingexplained.com\/wp-json\/wp\/v2\/comments?post=1555"}],"version-history":[{"count":4,"href":"https:\/\/codingexplained.com\/wp-json\/wp\/v2\/posts\/1555\/revisions"}],"predecessor-version":[{"id":1578,"href":"https:\/\/codingexplained.com\/wp-json\/wp\/v2\/posts\/1555\/revisions\/1578"}],"wp:attachment":[{"href":"https:\/\/codingexplained.com\/wp-json\/wp\/v2\/media?parent=1555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codingexplained.com\/wp-json\/wp\/v2\/categories?post=1555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codingexplained.com\/wp-json\/wp\/v2\/tags?post=1555"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/codingexplained.com\/wp-json\/wp\/v2\/series?post=1555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}