Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Open declaration in Java project

In an Eclipse SVN project I have a problem; when I tried to open a declaration of one class, I got this error:

Problems opening an editor Reason : projectname does not exist. 

Also refactoring does not work.

I have searched the web and tried all found solutions but nothing helped. I have downloaded different Eclipse and Java versions and switched to a clean workspace but I still have the problem.

How can I solve my problem or which solution can I try?

like image 565
Taegug Avatar asked Jan 08 '13 01:01

Taegug


People also ask

How do I open an existing Java project?

Simple, you just open klik file -> import -> General -> existing project into workspace -> browse file in your directory.

How do I enable open declaration in Eclipse?

Right Click on the project -> Properties -> Project Facets -> Click on the Configuration Link -> Click on Apply Button -> Click on OK button.

How to create a Java class in Eclipse?

Step 1:Open Eclipse and click File > New > Java Project. Step 2:Provide the Project Nameand click on the Finishbutton. Step 3:In the Package Explorer(left-hand side of the window) select the project which you have created. Step 4:Right-click on the srcfolder, select New > Classfrom the submenu. Provide the Class nameand click on Finishbutton.

How to run Java program in Eclipse?

How to Run Java Program in eclipse. In this section, we learn how to run a Java program in eclipse step by step. Step 1:Open Eclipse and click File > New > Java Project. Step 2:Provide the Project Nameand click on the Finishbutton. Step 3:In the Package Explorer(left-hand side of the window) select the project which you have created.

How to fix Eclipse > Java > open linked resources sources?

Possible duplicate of eclipse > java > open linked resources sources (.java instead of .class )? Double click on your project in eclipse -> Maven -> Enable Workspace Resolution I had this problem and I already had Enable Workspace Resolution enabled. Disabling and re-enabling seems to have resolved this.

Why can't I edit a JAR file in Eclipse?

The typical reason for this is if you have a jar file containing previously compiled classes on your build path before (or instead) of the project containing the source you want. This is very rarely desirable as it can take quite a while to discover that your edits do not take effect.


2 Answers

Right Click on the project -> Properties -> Project Facets -> Click on the Configuration Link -> Click on Apply Button -> Click on OK button.

The above steps should set your project as a Java project.

like image 129
Jay Avatar answered Sep 17 '22 14:09

Jay


If the project is a multi-module Maven project, then you need to import the child/module projects in addition to the parent/pom project. Then ensure that you only open source files via the child project. Java files opened this way will have the Refactor right-click menu item, and F3 Open Declaration etc. work properly. However if the Java file is opened from the parent project, these Eclipse functions will be missing.

It's quite frustrating when opening a file via a Search result, as the file will be found and listed in both the parent and child project. You need to ensure you only work with the file accessed via the child project.

I can't explain precisely what's going on with Eclipse, but it appears that Eclipse does not recognize the parent project as being Java projects, although it will correctly syntax-highlight the Java files whether they are accessed via the parent or child project.

like image 33
mrjmh Avatar answered Sep 21 '22 14:09

mrjmh