Viewing contents of a .jar file

后端 未结 30 938
一向
一向 2020-12-02 03:54

What would be the easiest way to view classes, methods, properties, etc. inside a jar file? I\'m looking for something equivalent to the very useful Lutz Roeder .NET Ref

相关标签:
30条回答
  • 2020-12-02 04:45

    Eclipse 3.4 JDT

    It is not the quickest way because you have to drag it into your eclipse first. But you will have full java class browsing, even with decompile enabled.

    0 讨论(0)
  • 2020-12-02 04:47
    jar -tvf file_name.jar
    

    above will only print names of the files.

    To view the content of files, you can extract the files in a folder by:

    jar -xvf file_name.jar
    

    this will unzip jar file & put the content in same directory where you are running this.

    Or in Windows rename .jar file to .zip & then you can unzip to extract & view the content of jar file. As jar is internally a zip file.

    0 讨论(0)
  • 2020-12-02 04:47

    java -xf some-j.jar will unzip a JAR file.

    0 讨论(0)
  • 2020-12-02 04:48

    Method names, fields, etc.

    By adding a jar to a project in an IDE, you can usually see methods and field names, but not the detailed implementation. NetBeans can do it, Eclipse probably, IntelliJ probably, etc. You can browse the jar structure directly within the IDE.

    Just the contents

    For anything such as viewing the contents, you could use :

    • jar tvf jarfile.jar
    • winzip or any zip tool

    The source code

    To access source code, you would use a decompiler such as JAD or one of its frontends or another decompiler. If the code is obfuscated, then ...

    0 讨论(0)
  • 2020-12-02 04:48

    My requirement was to view the content of a file (like a property file) inside the jar, without actually extracting the jar. If anyone reached this thread just like me, try this command -

    unzip -p myjar.jar myfile.txt
    

    This worked well for me!

    0 讨论(0)
  • 2020-12-02 04:49

    Using the JDK, jar -tf will list the files in the jar. javap will give you more details from a particular class file.

    0 讨论(0)
提交回复
热议问题