I recently started using IntelliJ IDE for one of my college classes and whenever I try to run a Java program using the Run button, it results in an error that says:
Error: Could not find or load main class helloWorld
Caused by: java.lang.ClassNotFoundException: helloWorld
The class is clearly in the working directory and named correctly. This is happening to any/every project I create and run using IntelliJ. Everything was working fine up until about a week or so ago so I'm not sure if there was an IntelliJ/Mac update thats causing this problem or what. All my projects run fine on VSCode, so it makes me think that the issue has to do with IntelliJ rather than the project itself or its files. Simple hello world projects run fine using the command line, but this class has a larger, more complex project where using the command line to compile and run every time is long and tedious, so I want to avoid being dependent on that. Ive tried deleting the .iml files and .idea folder to no avail.
Try and check your module settings go to "File" > "Project Structure" and then navigate to "modules" and make sure that your source directory is marked as a source root.
And then try and rebuild the project "Build" > "Rebuild Project".