1
votes

I'm fairly new to Intellij and Java and am unable to use libraries from one "module" in another. I am seeing red class names and getting "Cannot resolve symbol ..." errors all over the place:

enter image description here

The other modules are referenced in File | Project Structure all the other module's Paths are correct and include the *.classes I'm trying to use:

enter image description here

I have also tried a File | Invalidate Caches but am still having the same problems.

What do I need to do to fix this?

4

4 Answers

3
votes

Listed below are steps which may fix the problem:

1.Invalidate and refresh the IntelliJ's caches

File Menu -> Invalidate Caches / Restart -> Invalidate and restart

2.Project SDK selection

Check project settings from File Menu -> Project Structure Ensure an SDK is selected for the Project SDK. If is selected, click the 'New' button, select JDK and then select the correct path to the JDK e.g. /opt/java/jdk1.8 or c:\Java\Jdk1.8

3.Corrupt JDK

There may be a problem with your JDK installation, re-install JDK

4.Re-import the project

Close the project if it is open in IntelliJ Delete the .idea folder in the project source code folder. Start IntelliJ and Import the project.

You can choose any of them which will work for you.

2
votes

You need to add your external libraries/classes under dependencies in order for IDEA to see them when doing code analysis/autocomplete.

0
votes

After you add dependencies to POM file, make it a habit to refresh POM by clicking on the 'Reimports maven projects' icon. Its the first icon in the maven tool window located to the right of the main intellij editor. Its a blue icon with 2 circular arrows. Clicking it ensures that the added dependencies are fully integrated into your project

0
votes

You can go to "File->Project Structure"

From "Project Settings", Select "Project" tab and there make sure that "Project SDK" has proper JDK selection.

enter image description here