How can I open and see within a file within a jar file from within Terminal?
I can use less to print out all the files within the jar file, but how can I open these files?
Using unzip you can pipe a file from the archive to stdout and then into something else to read it, like:
From memory unzip is not installed by default so you might need to:
jar files are really only zip files you can test this by doing.
so to list the files you can simple do.
To access the files just unzip the file with
If you want to extract only one file then append the files after
Make sure to use the full path from -l. And keep in mind it will create the same path locally.
Personally I use
Extract contents to pwd
Extract specific file, creating dirs as required
Extracting the bytecode itself isn't usually terribly useful though. To make sense of it, you need to decompile it into something readable.
There aren't many good java decompilers to choose from. I tend to use JD-GUI, because it's quick and does what I need it to. Frustratingly, its multi-file search functionality never works for me (note that Ctrl+F search-on-the-page is fine). This is no great loss though; you can get it to dump all the sources to disk with Ctrl+Alt+S for perusal with grep/vim/Eclipse etc.
I install it like this:
Using it goes something like this:
Note however that JD-GUI has no CLI interface. If you know of a good CLI decompiler, I'd be very interested to hear of it (there is JAD, but AFAIK that only supports Java < 1.5).