Eclipse opens different source file than the edita

2019-05-11 06:16发布

问题:

When I run an application into eclipse, if an exception is thrown and is showed in the console, then you are able to click on the links which takes you to the source code file.

Fine, the problem is that when I click those links they open as external uneditable resources (different icon in the editor tab, Java source files have a blue J but these files have the J empty, only showing the border). Same problem when debugging, the files opened are not the same tabs as the ones edited.

For more information, while the normal source files shows in the title bar something like:

project/path/to/source/file.java

The others show its complete path:

C:\absolut\path\to\source\file.java

This is quite annoying since I have to go and back from one to the other and I have no idea where to change this or why it is happening (it was alright a time ago).

Any hints on how to edit this? Thanks

回答1:

It is a classpath problem. When you click, you are actually accessing the file from the classpath.

To view the Java file, you have to add a reference to your project in the classpath and move it to the top of the classpath list.



回答2:

You can also try converting it to project facets java version, right click on project --> properties --> choose Project Facets -->java 1.7 or [your version]. Apply.