Linux:查看.jar​​文件内容最方便的方法是什么

Linux:查看.jar​​文件内容最方便的方法是什么

不使用 unzip/untar 命令查看 .jar 文件内容的最便捷方法是什么?我想要做的是 - 使用cd命令浏览内部,就像浏览通常的文件夹一样,查看内容、类的大小 - 'ls -la'

MC允许即时执行此操作。有没有易于使用的替代方案?

答案1

使用 Java SDK 附带的 jar 工具列出 jar 文件的内容。如http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jar.html

$ jar tvf jarfile.jar

答案2

使用 vim 查看和编辑 jar 文件的内容(无需解压):

像这样在 vim 中打开 jar:

vim rabbitmq-client.jar

您将看到一个文件列表:

1 " zip.vim version v22
2 " Browsing zipfile /var/www/sandbox/eric/rabbitmq-client.jar
3 " Select a file with cursor and press ENTER
4
5 META-INF/
6 META-INF/MANIFEST.MF
7 com/
8 com/rabbitmq/
9 com/rabbitmq/client/
10 com/rabbitmq/client/impl/
11 com/rabbitmq/client/impl/recovery/
12 com/rabbitmq/tools/
13 com/rabbitmq/tools/json/
14 com/rabbitmq/tools/jsonrpc/
15 com/rabbitmq/utility/

将光标放在 上META-INF/MANIFEST.MF并按Enter。您会看到以下内容:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.6.0_31-b31 (Sun Microsystems Inc.)
Export-Package: com.rabbitmq.client;version="3.3.5";uses:="com.rabbitm
 q.client.impl,com.rabbitmq.utility,javax.net,javax.net.ssl,javax.secu
 rity.auth.callback,javax.security.sasl",com.rabbitmq.client.impl;vers
 ion="3.3.5";uses:="com.rabbitmq.client,com.rabbitmq.utility,javax.net
 ",com.rabbitmq.client.impl.recovery;version="3.3.5";uses:="com.rabbit
 mq.client,com.rabbitmq.client.impl",com.rabbitmq.tools;version="3.3.5
 ";uses:="com.rabbitmq.utility",com.rabbitmq.tools.json;version="3.3.5
 ",com.rabbitmq.tools.jsonrpc;version="3.3.5";uses:="com.rabbitmq.clie
 nt",com.rabbitmq.utility;version="3.3.5"
Bundle-Vendor: SpringSource
Bundle-Version: 3.3.5
Tool: Bundlor 1.0.0.RELEASE
Bundle-Name: RabbitMQ Java AMQP client library
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.rabbitmq.client
Import-Package: javax.net;version="0",javax.net.ssl;version="0",javax.
 security.auth.callback;version="0",javax.security.sasl;version="0"

Name: rabbitmq-client
Specification-Title: AMQP
Specification-Version: 0.9.1
Specification-Vendor: AMQP Working Group (www.amqp.org)
Implementation-Title: RabbitMQ
Implementation-Version: 3.3.5
Implementation-Vendor: Rabbit Technologies Ltd. (www.rabbitmq.com)

使用常规 vim 编辑命令更改几行。

press 'i' to enter insert mode
edit your lines
press :wq<enter> to write and quit

您将返回到 jar 中的文件列表,退出。

:q <enter>

检查更改是否是永久性的:

Follow the above steps again to inspect the file again, 
the change should still be there.

答案3

这对我来说就足够了:

unzip -l <jarfile>

答案4

我认为.jar文件基本上就是.zip文件。所以,我猜,fuse-zip可以工作。

相关内容