Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / February 2005

Tip: Looking for answers? Try searching our database.

How to list (from command line) all files in a "jar" archive ?

Thread view: 
Thomas Stien - 06 Feb 2005 13:25 GMT
I thought

jar -t myarchive.jar

resp

jar -t myarchive.jar *.*

will do the job. But when I entered exactly this command at the command prompt then
there is NO response from jar.exe. It keeps on running without any output.

How do I list all files in a jar archive with a command line command oterhwise ?

Thomas
klynn47@comcast.net - 06 Feb 2005 13:57 GMT
try jar -tvf myarchive.jar
Michael Klaus - 06 Feb 2005 14:07 GMT
> jar -t myarchive.jar

try
jar tf myarchive.jar

jar sticks to the syntax of tar, which means it reads from the standard
input normally. That's why you need the "f" switch.

Regards,
       Michael
David Rabinowitz - 06 Feb 2005 14:12 GMT
jar tvf my.jar

> I thought
>
[quoted text clipped - 10 lines]
>
> Thomas
Roland - 06 Feb 2005 14:41 GMT
> I thought
>
[quoted text clipped - 10 lines]
>
> Thomas

Try
    jar -tf myarchive.jar

Without -f option, the jar program expects the contents of the jarfile
from standard input. If you use
    jar -t myarchive.jar
you actually request the jar prog to list the entry 'myarchive.jar' from
a jarfile coming from stdin. Because you don't type anything on stdin it
just keeps waiting (if you would type something and hit return, you'll
get an error).
You could use your form by redirecting the contents of the jarfile to stdin:
    jar -t < myarchive.jar
HTH,
Signature

Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \

Malte - 06 Feb 2005 15:11 GMT
> I thought
>
[quoted text clipped - 10 lines]
>
> Thomas

What does

jar -tf myarchive.jar

do?
Karsten Baumgarten - 06 Feb 2005 15:26 GMT
> I thought
>
[quoted text clipped - 10 lines]
>
> Thomas

jar tf <jarfile>

Regards,

Karsten
Menno Holscher - 06 Feb 2005 15:47 GMT
> I thought
>
[quoted text clipped - 12 lines]
>
> Thomas
Try jar -tf myarchive.jar

Signature

Groeten van/regards

Menno

myersj@gmail.com - 06 Feb 2005 15:56 GMT
Try
jar -tf myarchive.jar

Without the f, jar expects input from standard input (that's why it
just sat there waiting)

Hope this helps,
- Jeff
Chuck Simpson - 06 Feb 2005 16:13 GMT
> I thought
>
[quoted text clipped - 12 lines]
>
> Thomas

Try:
    jar -tf myarchive.jar
or
    jar -tvf myarchive.jar

-t = list contents of jar (REQUIRED)
-v = gives size and last modification date in addition to name (OPTIONAL)
-f = use the following pathname as the target jar (REQUIRED)

The -f is required to specify the the jar you want to list.

Download the documentation for the JRE/JDK you are using. The index.html
page in the docs folder has a link to Java Tools. The jar command is
described in detail there.

Chuck
Stefan Schulz - 06 Feb 2005 16:17 GMT
> jar -t myarchive.jar
>
> resp
>
> jar -t myarchive.jar *.*

jar -tf myarchive.jar ;) jar honors the tar syntax, which assumes stdin as
the source of data if no file is specified.

Signature

In pioneer days they used oxen for heavy pulling, and when one ox
couldn't budge a log, they didn't try to grow a larger ox. We shouldn't
be trying for bigger computers, but for more systems of computers.
          --- Rear Admiral Grace Murray Hopper

AnonC - 06 Feb 2005 19:46 GMT
> I thought
>
[quoted text clipped - 10 lines]
>
> Thomas

try this:

jar -tf jarname.jar

thnaks
hilz
Andreas Wollschlaeger - 06 Feb 2005 22:06 GMT
> I thought
>
[quoted text clipped - 10 lines]
>
> Thomas

RTFM: jar -tf ... should do the trick!

HTH :-)
Andreas
Anthony Borla - 06 Feb 2005 23:32 GMT
> I thought
>
[quoted text clipped - 10 lines]
> How do I list all files in a jar archive with a command line
> command oterhwise ?

Did you try:

   jar -tf myarchive.jar *.*

or:

   jar tf myarchive.jar *.*

Typing 'jar' on its own will dump help text on the console.

I hope this helps.

Anthony Borla

P.S.

For what it is worth, the UNIX 'tar' command [I wonder if they are related
;) ?] behaves in a similar manner - until you use the 'f' option to nominate
a file, it just happily 'waits', seemingly in limbo - and has caught me out
on more than one occasion.
Rhino - 07 Feb 2005 00:28 GMT
> I thought
>
[quoted text clipped - 8 lines]
>
> How do I list all files in a jar archive with a command line command oterhwise ?

1. Try

jar tf myarchive.jar

In other words, change -t to tf without the minus sign in your first
example. Your second example won't work because you have the wrong options
(-t instead of tf) and the *.* argument doesn't belong there at all.

2. (Re-) read the Java Tutorial section on Jar files. Here's the URL:
http://java.sun.com/docs/books/tutorial/jar/

Rhino
Jim - 07 Feb 2005 03:40 GMT
>I thought
>
[quoted text clipped - 10 lines]
>
>Thomas

You didn't specify the filename, try

jar -tf myarchive.jar
Robert Klemme - 07 Feb 2005 09:34 GMT
> I thought
>
[quoted text clipped - 8 lines]
>
> How do I list all files in a jar archive with a command line command oterhwise ?

You forgot -f.

jar -tf myarchive.jar

Kind regards

   robert
John C. Bollinger - 07 Feb 2005 13:57 GMT
> I thought
>
[quoted text clipped - 6 lines]
> will do the job. But when I entered exactly this command at the command prompt then
> there is NO response from jar.exe. It keeps on running without any output.

The jar, tool, like its pseudo-namesake, tar, reads from the standard
input unless you specify a file with the -f option.  Thus,

jar -tf myarchive.jar

should do what you want, but the variants you tried block on input (from
the terminal, since you didn't redirect jar's standard input.

John Bollinger
jobollin@indiana.edu
listsubscriber@hotmail.com - 07 Feb 2005 14:59 GMT
Hopefully you are running a flavor of Linux.  From the command line do
this:

>  find /pathYouWantToSearch -name "*.jar"  -exec unzip -l {}  \;

This will list all the files in all the jars the find command locates.
You can specify the exact name of the jar if you only want to do one
jar file.   If you don't want to use find, or you are stuck using a
Windoze machine, do this:

> unzip -l pathToTheJarFile.jar

Get a command line unzip util for Windoze .... preferrably Info-Zip
5.51.  I'm sure you can use the jar command for this type of exercise,
but Unzip has worked for me ALL the time and jar -t works sometimes.
Actually, jar -t has NEVER worked for me.  Jar -tf jarFile.jar or jar
-vf jarFile.jar or jar -tvf jarFile.jar works decently.

Thanks.
markscottwright@gmail.com - 07 Feb 2005 15:16 GMT
You to have "-f" before the filename.  So, tar -t -f abc.jar, or just
tar -tf abc.jar.
Ian Shef - 07 Feb 2005 19:22 GMT
> I thought
>
[quoted text clipped - 10 lines]
> How do I list all files in a jar archive with a command line command
> oterhwise ?

From Reading The Friendly Manual (RTFM) at
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jar.html  :

    List table of contents of jar file
       jar t[v]f jarfile [inputfiles] [-Joption]
       jar t[v] [inputfiles] [-Joption]

Note that there is no dash ahead of the options. Note also that without the
"f" option, the jarfile will be taken from standard input, which is why
jar.exe keeps running without any output.
Thus, the command is:

    jar tf myarchive.jar

The documentation is downloadable and very worthwhile to have around.
jar files are just a special case of zip files.  If you have a zip tool
(e.g. WinZip), you should be able to view using that tool.  For creating
jar files with proper manifests, you are probably better off using jar.

> Thomas

Signature

Ian Shef     805/F6      *    These are my personal opinions    
Raytheon Company         *    and not those of my employer.
PO Box 11337             *
Tucson, AZ 85734-1337    *

n@th@n - 09 Feb 2005 15:54 GMT
> I thought
>
[quoted text clipped - 10 lines]
>
> Thomas

Thomas,

You need to specify the file with the -f flag....Try this:

jar -tf myarchive.jar

Hope this helps,

-nathan


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.