Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-14-2010, 08:31 PM   #1
LQ Newbie
Registered: Oct 2007
Posts: 22

Rep: Reputation: 0
How do I extract war file under Linux Red Hat Enterprise server 5.0?

I am using a Red Hat enterprise server 5.0

I would like to know if there is a way to extract a single file from inside a war file and display its contents on the screen?

For example:
I have a file labeled test.war and inside this war there are multiple files/directories. I am interested in seeing the contents of one file labeled MANIFEST.MF without having to unzip the entire war file. does it make sense?
Old 04-14-2010, 08:57 PM   #2
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702

Rep: Reputation: 43
Old 04-15-2010, 02:38 AM   #3
Registered: May 2001
Posts: 74

Rep: Reputation: 15
If my memory serves me well tonite, a war file is a web archive file for deploying servlets. Try going to help with that.

Last edited by iamnotherbert; 04-15-2010 at 02:49 AM.
Old 04-15-2010, 06:23 AM   #4
Registered: Jul 2004
Location: Zinzinnati, OH
Distribution: RH, FC 1-6, F 7-21, Debian, LinuxPPC, Knoppix, Ubuntu, Yellow Dog
Posts: 176

Rep: Reputation: 31
Try jar xvf file_name.war. I know of a way to do it in Eclipse or a Java program; not sure about doing it on the fly.

Last edited by cincindie; 04-15-2010 at 06:25 AM. Reason: Adding content.
Old 04-15-2010, 06:36 AM   #5
Registered: Dec 2006
Distribution: Arch
Posts: 44

Rep: Reputation: 15
I think you can use the 'u' switch to jar

ie To extract the single file apssession.jar...

jar uxvf app.war WEB-INF/lib/appsession.jar
Old 04-15-2010, 07:59 AM   #6
LQ Newbie
Registered: Aug 2005
Distribution: Ubuntu
Posts: 5

Rep: Reputation: 0
Jars/Wars are usually stored as a ZIP compressed file.

This works for me to extract the contents of a file to stdout:
unzip -c whatever.war META-INF/MANIFEST.MF

See man unzip for more options.
Old 04-16-2010, 06:04 PM   #7
LQ Newbie
Registered: Oct 2007
Posts: 22

Original Poster
Rep: Reputation: 0
Thanks everyone for your feedback.

I used the unzip option and it did the trick.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip][list] [-x xlist] [-d exdir]
Default action is to extract files in list, except those in xlist, to exdir;
file[.zip] may be a wildcard. -Z => ZipInfo mode ("unzip -Z" for usage).

-p extract files to pipe, no messages -l list files (short format)
-f freshen existing files, create none -t test compressed archive data
-u update files, create if necessary -z display archive comment
-x exclude files that follow (in xlist) -d extract files into exdir

modifiers: -q quiet mode (-qq => quieter)
-n never overwrite existing files -a auto-convert any text files
-o overwrite files WITHOUT prompting -aa treat ALL files as text
-j junk paths (do not make directories) -v be verbose/print version info
-C match filenames case-insensitively -L make (some) names lowercase
-X restore UID/GID info -V retain VMS version numbers
-K keep setuid/setgid/tacky permissions -M pipe through "more" pager
Examples (see unzip.txt for more info):
unzip data1 -x joe => extract all files except joe from zipfile
unzip -p foo | more => send contents of via pipe into program more
unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Kickstart Configurator Problem - Red Hat Enterprise Linux server 5 sj_johney Linux - Server 7 04-22-2012 11:47 AM
How To setup remote access server on Red Hat Enterprise Linux Server release 5.1 bagra Linux - Newbie 5 10-19-2011 08:04 PM
External HDD on Red Hat Enterprise Linux Server release 5.3 issue mdmazaza Linux - Newbie 7 04-09-2009 03:24 PM
Red Hat Enterprise Linux 3 web server? Superfrk Linux - Enterprise 1 06-27-2004 02:11 AM
Upgrading Red Hat 9 to Red Hat Enterprise Server 3 AS louisb Linux - Software 7 02-23-2004 11:25 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:08 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration