I make this call to a static singleton instance from the class GameManager.java
.
HUD.getInstance().update(timeDelta);
HU
Make sure the source file of the java class you are trying to refer to has a .java
extension. It was .aj
in my case (I must have hit "Create aspect" instead of "Create class" when creating it). IntelliJ shows the same icon for this file as for "normal" class, but compiler does not see it when building.
Changing .aj
to .java
fixed it in my case.
recompiling the main Application.java class did it for me, right click on class > Recompile
I faced the same problem, and there are a lot of solutions given in the answer, trying all these solutions took me quite some time, so here I would like to propose a methodical approach if you get this error.
Check for the following things, create/update if something is missing
If everything is fine, you can try following solutions in given order
Recompile the file/module
If that didn't fix the issue, try refreshing maven dependency and building the project using Maven -> Reimport
and Build -> Rebuild Project
Try mvn clean install -DskipTests
Try invalidating the IntelliJ cache and restarting the IDE, using File > Invalidate caches/ restart
Delete the .idea folder and reimport the project
Credit and Thanks to everyone who answered this question, you can refer to their answers for more description regarding each point.
I had the same problem and fixed it by clicking File>Invalidate caches/ restart
Thanks for the help so far, turns out the fix was to compile HUD.java first (right click on the file-> Compile HUD.java). After compiling the java file the rest of the project could be compiled without any problems.
I don't really know why this fixed it, or why IntelliJ wouldn't do this automatically, but root error seems it has to do with IntelliJ not correctly handling having multiple classes in a single .java file.
Select Build->Rebuild Project will solve it