Eclipse> java> open source sources of resources (.java instead of .class)?

I have 2 projects, A and B

project B has a class A folder in its path to build> the library (eclipse also acknowledged that there is a "source attachment" and added it.

Both A and B are in the same workspace.

When I press Ctrl + click on the project A function that references the eclipse file B, open the .class A file. But if I need to edit the version of this t21 file, I have to manually search for filename in project A and open it from the project explorer.

Is there no simpler way to go from a linked resource to a → .java file of its source? or is it easier to switch from .class to .java than manually expand the folders and open the file?

Thank you francesco

+4
source share
4 answers

You can use Ctrl + Shift + T to open the search dialog.

But you have to add B as a dependent project of A (and remove it from the classpath).

enter image description here

+5
source

Another solution for the case:

One neat feature of Eclipse (and other IDEs) is that you can hold CTRL and click on a function or variable to go to its definition.

The problem that can occur in Eclipse is that it opens a .class file (a compiled file) instead of opening a .java file when you do this. This is probably caused by the order of the entries in the .classpath.

Go to the project directory and open the .classpath file. Move all introduces a classpathentry type with an attribute of the form = "src" to the beginning of the file (or at least above any entries with the form "output").

Restart Eclipse and the problem should be fixed.

Found on this page

+3
source

Remove project A from "build path> libraries" and put it in "build path> projects".

+2
source

Go to Project-> Properties-> Java Build Path.

In order and export, all src files are saved on top and selected.

Eclipse will now select .java files on top of .class

+2
source

Source: https://habr.com/ru/post/1387552/


All Articles