How to get Java Decompiler / JD / JD-Eclipse running in Eclipse Helios
Asked Answered
T

14

47

Java Decompiler (JD) is generally recommended as a good, well, Java Decompiler. JD-Eclipse is the Eclipse plugin for JD.

I had problems on several different machines to get the plugin running. Whenever I tried to open a .class file, the standard "Source not found" editor would show, displaying lowlevel bytecode disassembly, not the Java source output you'd expect from a decompiler.

Installation docs in http://java.decompiler.free.fr/?q=jdeclipse are not bad but quite vague when it comes to troubleshooting.

Opening this question to collect additional information: What problems did you encounter before JD was running in Eclipse Helios? What was the solution?

Trovillion answered 22/12, 2010 at 17:50 Comment(2)
I made the steps 1, 2, 3 and the 7. and I put the folder with the class files in the project build path (right click, properties, java build path, libraries, add class folder, create new folder, advanced>>, link to folder in the file system, browse,...) then restart eclipse.Glossary
The new home of JD-Eclipse is: jd.benow.ca/#jd-eclipseIsoniazid
T
37

Here's the stuff I ran into:

1) RTFM and install the "Microsoft Visual C++ 2008 SP1 Redistributable Package" mentioned at top of the installation docs. I missed this at first because the Helios instructions are at the end.

2) Close all open editor tabs before opening a class file. Otherwise it's easy to get an outdated editor tab from a previous attempt.

3) Open the class file in the "Java Class File Editor" (not "Java Class File Viewer"). Use "Open With" in the context menu to get the right editor. If pleased with results, make it the default editor in the File Association settings, in Window/Preference General/Editors/File Associations select *.class to open with "Java Class File Editor".

4) This guy recommends installing the Equinox SDK from the Helios update site. I did, but I'm not sure if this was really necessary. Anyone know?

5) If the class files you are trying to view are in an Eclipse Java project, they need to be in the project's build path. Otherwise, an exception ("Not in the build path") will show up in the Eclipse error log, and decompile will fail. I added the class files as a library / class file folder to the build path.

6) Drag/dropping a class file from Windows Explorer or opening it with File/Open File... will not work. In my tests, I gives a "Could not open the editor: The Class File Viewer cannot handle the given input ('org.eclipse.ui.ide.FileStoreEditorInput')." error. That is probably the wrong editor anyways, see 3).

7) After getting the plugin basically running, some files would still not decompile for an unknown reason. This disappeared after closing all tabs, restarting Helios, and trying again.

Trovillion answered 22/12, 2010 at 18:7 Comment(7)
I would be able to execute step 5 if I could see it the the dialog window to add a library or class folder.; but I can`t. I also can't find instructions anywhere as to how to use this decompilerUmberto
The second part of step 3 was key for me in Eclipse 4.2M5. There's no Open With in the context menu, so you need to add Class File Editor under File Associations for "*.class without source" and make it the default.Chinchin
I see "Class File Editor", not "Java Class File Editor". (Eclipse Indigo SR2) But choosing "Class File Editor", it still opens the old "Class File Viewer". What's wrong? Why the hell is this so difficult?Thole
@Leo In eclipse Juno set *.class without source editor to class file editor. Changing settings for *.class may not work.Menton
@Kshitiz: The problem was that the opened .class file was not in the classpath. See my Full Answer below.Thole
+1 Got it working without step 4. However, it didn't work until I set up the association to *.class without source. Until then, it would just display the "org.eclipse.ui.ide.FileStoreEditorInput" error.Tribulation
.class file or the project should be on the classpath. Otherwise it doesn't work for me even after associating the appropriate Editor in the File Association option.Weatherby
W
19

To Make it work in Eclipse Juno - I had to do some additional steps.

In General -> Editors -> File Association

  1. Select "*.class" and mark "Class File Editor" as default
  2. Select "*.class without source" -> Add -> "Class File Editor" -> Make it as default
  3. Restart eclipse
Wexler answered 10/4, 2013 at 12:23 Comment(0)
T
9

The JD-eclipse plugin 0.1.3 can only decompile .class files that are visible from the classpath/Build Path.

If your class resides in a .jar, you may simply add this jar to the Build Path as another library. From the Package Explorer browse your new library and open the class in the Class File Editor.

If you want to decompile any class on the file system, it has to reside in the appropriate folder hierachy, and the root folder has to be included in the build path. Here is an example:

  1. Class is foo.bar.MyClass in .../someDir/foo/bar/MyClass.class
  2. In your Eclipse project, add a folder with arbitrary name aClassDir, which links to .../someDir.
  3. Add that linked folder to the Build Path of the project.
  4. Use the Navigator View to navigate and open the .class file in the Class File Editor. (Note: Plain .class files on the file system are hidden in the Package Explorer view.)

Note: If someDir is a subfolder of your project, you might be able to skip step 2 (link folder) and add it directly to the Build Path. But that does not work, if it is the compiler output folder of the Eclipse project.

P.S. I wish I could just double click any .class file in any project subfolder without the need to have it in the classpath...

Thole answered 14/6, 2012 at 14:0 Comment(1)
Most useful answer of the bunch. Thanks!Teens
A
6

I am using Eclipse 3.7 Indigo and Windows 7 64-bit:

What I did was to install the Microsoft Visual C++ 2008 SP1 Redistributable Package as suggested by the site and reminded by @Universalspezialist.

Then install the plugin as stated in the site: http://java.decompiler.free.fr/?q=jdeclipse

Go to preference, then find "File Associations" Click on the *.class, then set the "class File Editor" as default.

Restart Eclipse perhaps? (I did this, but I'm not sure if it's necessary or not)

Astrolabe answered 22/12, 2010 at 17:51 Comment(0)
J
6

Simple thing i did to get it working:

Went in eclipse > Window > Preferences

(Optional)typed in the search box "file" to help trim the tree of options. Went to General > Editors > File associations.

Clicked the ".class" type. Below there were 2 editors present, i clicked on the "Class File Editor" - the one with the icon from JD, clicked the "Default" button on the right.

Done. Now all ur class are belong to us.

Jokester answered 25/2, 2012 at 16:48 Comment(0)
R
6

After testing on Juno, Kepler and Luna, I found JD only works for *.class files on build path.

  1. Adding the jar as a lib of an existing project
  2. Go to Preferences->General->Editors->File Associations, set *.class without source to Class File Editor with a cup icon
Root answered 30/11, 2014 at 2:8 Comment(3)
This solution worked for me on Eclipse Oxygen. I also set "JD Class File Viewer" as the default for "*.class without source".Hispidulous
this solution worked for me for Eclipse 2020-03, the build path trick is necessary, Thank you !Seadon
Worked for me as well on Eclipse 2020-12Ge
C
3

I use jadeclipse instead, because it can't work in 3.6/3.7 eclipse

Update site http://webobjects.mdimension.com/jadclipse/3.6/

Intallation http://5thcross.wordpress.com/2009/05/20/installing-jadclipse-in-eclipse/

Cayuga answered 5/8, 2011 at 9:4 Comment(2)
Thanks, I tried JD but actually the update site link is broken.Aida
Just did this after trying and failing at everything outlined in this article. (Eclipse 2.9.2) JAD Update site works fine, Installation seems to work fineMole
S
3

JAD Decomplier plug-in for Eclipse version 3.x and 4.x.

update site: http://feeling.sourceforge.net/update

Steps:

  1. Open Eclipse IDE.
  2. Click Help->Install New software
  3. Paste above URL and give name as JAD.
  4. Select the Eclipse Class Decompiler
  5. Click on Next and accept agreements
  6. Install it.
  7. Restart Eclipse and check now.
Silber answered 19/11, 2013 at 10:59 Comment(3)
"Document couldn't be loaded by browser" -- I almost downvoted this. I eventually figured out that I need to put that link into Eclipse... could have been stated more clearly. I got it installed and working, thanks! Maybe better to reference marketplace.eclipse.org/content/jadclipse-eclipse-4x.Blunderbuss
This works perfectly with Spring Tool Suite 3.4. Very useful for those who are facing issues with jadclipse.Briant
Why do you post the installation steps for JADclipse, when the question is about JD-Eclipse?Donetta
P
2

if you need to decompile standalone jar try JD-GUI by the same autor (of JD-Eclipse). It is a standalone application (does not need eclipse). It can open both *.class and *.jar files. Interesting enough it needs .Net installed (as do JD-Eclipse indeed), but otherwise works like a charm.

Find it here:

http://jd.benow.ca/

Regards,

Placia answered 5/6, 2015 at 15:31 Comment(0)
G
1

I made the steps 1, 2, 3 and the 7. and I put the folder with the class files in the project build path (right click, properties, java build path, libraries, add class folder, create new folder, advanced>>, link to folder in the file system, browse,...) then restart eclipse.

Glossary answered 6/12, 2011 at 22:28 Comment(0)
A
1
  1. Download the JD-Eclipse Update Site(github.com/java-decompiler/jd-eclipse)
  2. Launch Eclipse,

  3. Click on "Help > Install New Software...",

  4. Click on button "Add..." to add an new repository,

  5. Enter "JD-Eclipse Update Site" and select the local site directory,

  6. Check "Java Decompiler Eclipse Plug-in",

  7. Next, next, next... and restart Eclipse.

Averment answered 10/8, 2018 at 18:1 Comment(0)
T
0

Just download the site from the JD page. I was able to install from a local site in the isntalled software section of eclipse.

Tricyclic answered 9/11, 2012 at 14:52 Comment(0)
L
0

Steps to add the Java Decompiler in Eclipse :

  1. Open Eclipse IDE.
  2. Click Help->Eclipse Marketplace Wizard
  3. In Search tab find the JD (JD is keyword to get the Eclipse Class Decompiler)
  4. Select the Eclipse Class Decompiler
  5. Click on Install.
  6. Restart Eclipse and check
Lezley answered 2/7, 2017 at 9:0 Comment(1)
Similar answer has been made before for this question.Bui
H
0

I used Intellij or Android studio both are working awesome for decompiling purpose. Internally Intellij following FernFlower Decompiler. enter image description here

Hookah answered 6/1, 2022 at 8:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.