Java cannot access class, class file not found
File -> Invalidate Caches/ Restart this worked for my after long hours of effectiveless
Try this
- Go to File
- Invalidate Caches/Restart
- You can choose only Invalidate and restart
(See Invalidate caches on IntelliJ's manual)
The project contained several modules. While the library was added to the project libraries, some modules lacked it in their dependency part. So I solved the problem using the following steps in IntelliJ
Creating a module library and adding it to the module dependencies:
- Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
- In the left-hand pane of the dialog, select Modules.
- In the pane to the right, select the module of interest.
- In the right-hand part of the dialog, on the Module page, select the Dependencies tab.
- On the Dependencies tab, click + (on the top right) and select Jars or directories.
- In the dialog that opens, select the necessary files and folders. These may
be individual .class and .java files, directories and archives
(.jar and .zip) containing such files as well as directories with
Java native libraries (.dll, .so or .jnilib). - Click OK. If necessary, select the Export option and change the dependency scope.
- Click OK in the Project Structure dialog.
Rebuilding project worked for me.