Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ can't find classes in same package when compiling

As an extension to my previous question (IntelliJ can't find depencency when compiling, but can in editor.) which got solved, I now have a new issue which has sprung up.

Within the same packages, references to other classes are showing up with errors:

enter image description here

As you can see in the picture, there is happening at the line involving the BifCreatorController, even though that class is in the same package as the BifCreatorView.

Just like my previous question, I am failing to understand why IntellJ is spitting out those errors. This project works just fine in Eclipse, but I am looking to start moving away from eclipse.

like image 470
E.S. Avatar asked Jan 13 '16 22:01

E.S.


People also ask

How do I see all classes in IntelliJ?

By default, IntelliJ IDEA shows all classes, methods, and other elements of the current file. To toggle the elements you want to show, click the corresponding buttons on the Structure tool window toolbar. to show class fields. to have protected class members shown in the tree.

How do I compile classes in IntelliJ?

Compile a single file or classOpen the needed file in the editor and from the main menu, select Build | Recompile 'class name' ( Ctrl+Shift+F9 ). Alternatively, in the Project tool window, right-click the class you need and from the context menu, select Recompile 'class name'.

How do I find class in IntelliJ project?

Ctrl+N : finds a class by name. Ctrl+Shift+N : finds any file or directory by name (supports CamelCase and snake_case).

How do I find my class path in IntelliJ?

find your project or sub-module and click on it to highlight it, then press F4, or right click and choose "Open Module Settings" (on IntelliJ 14 it became F12) click on the dependencies tab. Click the "+" button on the right and select "Jars or directories..." Find your path and click OK.


3 Answers

Got same problem today. Rebuilding or restarting both didn't work for me. In the end, I tried to rename the class, problem solved! Then I rename the class to the name I want, everthing was fine!

like image 82
liuyong Avatar answered Oct 20 '22 04:10

liuyong


This is because BifCreatorController is excluded from compilation (see the small "X" top-left icon near to the file name). One reason would be the file got some errors while compiling, IDEA proposed to exclude it from compilation and you had accepted.

Go to "File > Settings > Build, Execution, Deployment > Compiler > Excludes" and remove it from there.

like image 6
Ivaylo D. Ivanov Avatar answered Oct 20 '22 04:10

Ivaylo D. Ivanov


I had the same problem, i cleared the cache and restarted but it did not solve the problem. Then i right clicked the not found class and selected Recompile and after recompilation the problem was solved.

like image 5
velocity Avatar answered Oct 20 '22 04:10

velocity