39

On Linux i can use file-roller and open an browse the content of an EAR file without manually open it, can even dig into contained WAR file and within that JAR files quickly.

This is another of those must have tools I'm missing on OSX (along with meld).

Any good tools that can do this ?

Update: I found a tool that fits my needs : http://www.zipeg.com/

Honorable mention to midnight commander (MC) - but it's command line (but very fast) as well as newer versions of VI (which can go into zipped files)

Thibaut Colar
  • 919
  • 2
  • 9
  • 19
  • 3
    Rename the file to .zip and just open it using the built-in unzipping tool. – pickypg Jun 08 '11 at 20:20
  • Well i can do that even without renaming it, but it's just extracting it in the current folder (and will leave it there which i don't like), and more importantly it doesn't allow going into subarchives as i was requesting. – Thibaut Colar Jun 08 '11 at 20:22
  • I am off today. Missed the contained type request. In that case, have a look at [Jar Inspector](http://www.codeland.org). – pickypg Jun 08 '11 at 20:34
  • This is already closed but I have been using https://github.com/java-decompiler/jd-gui and I love it. – Josep Valls Jan 14 '16 at 20:04
  • What works really well is plain old Vim. It will allow you to open the war, select files and then view them. Alternatively if you looking for a "tool" Command One also does a great job on Mac. – Dane Balia Jul 06 '16 at 14:20
  • https://github.com/aonez/Keka works great – i000174 May 14 '19 at 08:15

4 Answers4

43

Any OS X ZIP utility that can open files without unpacking them will do. Alternatively, open a terminal window and type:

jar tvf <filename.jar>

You can drag the file from Finder to the Terminal window, and it will populate the filename for you. You can also pipe the output into less to scroll up and down.

jar tvf <filename.jar> | less
Pavel
  • 3,481
  • 26
  • 31
  • 1
    I know that, but that's not very convenient. I'm using this to "explore" a war/jar, and maybe pick one file deep within and open it (just that one) etc... – Thibaut Colar Jun 10 '11 at 14:48
10

I copy it to a ".zip" file and then use my zip utilities to peek inside.

.ears, .wars, and .jars are just zip files with additional required items packed inside.

If you want to extract the contents, you can unzip them. Java contains a jar command that provides ability to zip / unzip the archives (and extra verifications that the archives are properly jar files).

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138
8

You may also want to give Jarzilla a try.

depsypher
  • 1,084
  • 11
  • 20
  • 1
    Wow - that's awesome. Fast and extremely convenient, just drop your JAR file on it. Has search. – n13 Aug 10 '13 at 02:43
  • 4
    Update: JarZilla doesn't work on Mavericks. Oh, well. – n13 Oct 25 '13 at 14:25
  • 3
    It will work, but you need to turn off gatekeeper: Open Security & Privacy Preferences Change setting "Allow applications downloaded from" to setting "Anywhere" – depsypher Nov 12 '13 at 01:53
1

If you can't already do it, make sure you can see the file extension on the *.jar. Change the name to *.zip, which will allow you to open the file as if it were a ZIP file (which it is). When you're done playing with the *.class files, change it back to *.jar so you can execute the file.

Although this is somewhat tedious, it doesn't require any new program installations and thus can be done on any computer, with or without admin rights.

Ryan Amos
  • 5,422
  • 4
  • 36
  • 56