CLI: How to browse contents in a jar file? [duplicate]
Emily Wong
Inside a Ubuntu OS, how can I browse contents in a jar file by terminal?
02 Answers
You could use the command unzip -l [filename] to list the contents of the jar archive file.
First, you might need to install unzip:sudo apt install unzip
Example of unzip usage on the file gettext.jar:
username@ubuntu-server:~$ unzip -l /usr/share/java/gettext.jar
Archive: /usr/share/java/gettext.jar Length Date Time Name
--------- ---------- ----- ---- 0 2019-03-06 23:31 META-INF/ 66 2019-03-06 23:31 META-INF/MANIFEST.MF 5657 2019-03-06 23:31 gnu/gettext/DumpResource.class 699 2019-03-06 23:31 gnu/gettext/GetURL$1.class 1579 2019-03-06 23:31 gnu/gettext/GetURL.class
--------- ------- 8001 5 filesAlternatively, you could use the Java JDK's jar command to view the contents of a jar file: jar -tf [filename]. (See )
The basic format of the command for viewing the contents of a JAR file is:
jar tf jar-fileThe JAR tool will display additional information if you use the v option:
jar tvf TicTacToe.jar
If you don't have it, you should install jar with
sudo apt install openjdk-11-jdk-headless