good_evening
good_evening

Reputation: 21759

How to extract classes from .jar file?

I have .jar file. I tried running command jar xf my.jar it gave nothing. I tried using JD GUI, but it gave me this message: Invalid input file '/home/hey/Desktop/my.jar'.

Does it mean I can't extract classes from this .jar file?

Upvotes: 13

Views: 68207

Answers (5)

WickedW
WickedW

Reputation: 2601

How did you create your .jar file?

I just used Dex2Jar on MAC OSX like so -

sudo sh ~/Downloads/dex2jar-2.0/d2j-dex2jar.sh ~/mobile/pjr.mob.android/obj/Debug/android/bin/classes.dex --force

and the resulting file had a permissions issue, so when I went to open it with JD GUI it gave the "Invalid input fileloader:" error you mentioned above.

If you do a -

sudo chmod +xr ~/Downloads/dex2jar-2.0/classes-dex2jar.jar 

You will then be able to open it in JD GUI.

Upvotes: 7

Zibri
Zibri

Reputation: 9857

The answer of WickedW is correct!

sudo chmod +xr *.jar

then you can open the jar with jd-gui

Upvotes: 1

useless
useless

Reputation: 1906

for linux users

unzip your.jar

Upvotes: 7

Chandra Sekhar
Chandra Sekhar

Reputation: 16516

If you wish to extract a file from the Jar file, use the following command:

jar xf jar-filename archived-files

The x option indicates we wish to extract files, the f option indicates from a jar file, the jar-filename is the filename of the jar file to extract from and the archived-files are the files to extract.

We can also extract all files by simply not specifying which files to extract:

jar xf project.jar

Note: If it's not Accessible do like as @Legend told, Open With WinRaR check weather it's a proper .jar or .zip file. If it's not opening with winrar there may be problem in .jar/.zip.

Upvotes: 22

user1181445
user1181445

Reputation:

You can open the jar file with winrar, this will show all the class files within, from there, you can drag them all into JD-GUI and decompile them all.

Upvotes: 8

Related Questions