Extract source code from .jar file

后端 未结 11 934
名媛妹妹
名媛妹妹 2020-11-28 17:42

Is there a way to extract the source code from an executable .jar file (Java ME)?

相关标签:
11条回答
  • 2020-11-28 18:39

    I believe this can be done very easily. You can always extract the source files (Java files) of a jar file into a zip.

    Steps to get sources of a jar file as a zip :

    1. Download JAD from http://techieme.in/resources-needed/ and save it at any
      location on your system.
    2. Drag and drop the jar for which you want the sources on the JAD. 3 JAD UI will open with all the package structure in a tree format.
    3. Click on File menu and select save jar sources.
    4. It will save the sources as a zip with the same name as the jar.

    Hope this helps.

    The link is dead due to some reason so adding the link from where you can download the JDGUI

    0 讨论(0)
  • 2020-11-28 18:40

    Your JAR may contain source and javadoc, in which case you can simply use jar xf my.jar to extract them.

    Otherwise you can use a decompiler as mentioned in adarshr's answer:

    Use JD GUI. Open the application, drag and drop your JAR file into it.

    0 讨论(0)
  • 2020-11-28 18:40

    I know it's an old question Still thought it would help someone

    1) Go to your jar file's folder.

    2) change it's extension to .zip.

    3) You are good to go and can easily extract it by just double clicking it.

    Note: I tested this in MAC, it works. Hopefully it will work on windows too.

    0 讨论(0)
  • 2020-11-28 18:42

    Do the following on your linux box where java works (if u like the terminal way of doing things)

    cd ~
    mkdir decompiled_code && cd decompiled_code
    wget https://bitbucket.org/mstrobel/procyon/downloads/procyon-decompiler-0.5.36.jar
    java -jar procyon-decompiler-0.5.36.jar /Path/to/your/jar -o .
    

    NOTE : as @Richard commented "this may be illegal depending on whether you own the copyright to the jar, the country you live in and your purpose for doing it."

    0 讨论(0)
  • 2020-11-28 18:43

    AndroChef Java Decompiler produces very good code that you can use directly in your projects...

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