Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.class file opens instead of .java while debugging

Tags:

eclipse

Current setup:

  • MainProject which is a Library Project

  • BranchProject which is a new projects and has MainProject as a Reference

Whenever I debug and a file from MainProject is on focus (actually BranchProject has only graphic and xml layout changes) the Debug window opens a .class file which is read only. I want it to open the .java file so I can edit it directly.

like image 631
Alin Avatar asked Jul 18 '12 11:07

Alin


People also ask

How do I get a .java file from a .class file?

You can use a decompiler to do so. One of the most major ones is JD-GUI. JD-Core is a library that reconstructs Java source code from one or more “. class” files.

How do I debug a .class file?

There are two ways to debug a class file. The first way is to set the decompiler preference, and to realign the line number. The second way is to check the debug mode in the decompiler menu bar. When your Eclipse workspace is in debug perspective, the debug mode becomes the default.

How does a .class file differ from a .java file?

java file contains your Java source code while a . class file contains the Java bytecode produced by the Java compiler. It is your . class files that run on the JVM to execute a Java application.

How do I convert .class to .Java in Eclipse?

use Java Decompiler http://jd.benow.ca/ in it you can open jar, or . class and it will converted to java source.


1 Answers

Skyler's answer from this post worked for me: Opening source code from debug view edits .class after Android R18 update

Here is a summary: The fix is to right click the Project name in the debug view, and select "Edit Source Lookup..." from the menu. From there, remove the Default lookup path. After that, manually add the associated projects (not jars) that your project references. This is done by clicking Add, selecting Java Project, then checking the appropriate projects.

like image 147
Steven Avatar answered Nov 10 '22 17:11

Steven