Java files are orange; cannot run program

Answered

I am taking a beginner's course on Java and am having trouble getting a program to run in IntelliJ. This is what I see when I boot up one of the starter files provided in the course:

As you can see, all of the Java files have an orange icon next to them. Usually, when things are working properly, there is a blue icon next to them (and, in the case of the main file, a green "play" arrow).

I can neither run nor debug the program. In the event log I get the following message:

"Cannot load settings from file 'C:\Users\[redacted]\Desktop\Coding Projects\Courses\Software Construction - Data Abstraction\control-and-data-flow-lecture-starters\HairSalon2Starter\SimpleDebugExercises.iml': File C:\Users\[redacted]\Desktop\Coding Projects\Courses\Software Construction - Data Abstraction\control-and-data-flow-lecture-starters\HairSalon2Starter\SimpleDebugExercises.iml does not exist
Please correct the file content"

I checked the course setup instructions and I seem to have set up everything correctly, from the SDKs to the plugins. What am I doing wrong?

0
9 comments
Avatar
Permanently deleted user

Thanks. That kind of worked, but now I have two new problems:

1) I cannot run the program because I get the error: "Could not find or load main class ui.Main"

2) Every time I close the project and reopen it, it does not remember the new source root I assigned.

Here's what I'm seeing now (note that this is a different exercise than the one I linked to in my first post, which accounts for the image discrepancy):

0

Move the project outside of OneDrive folder.

See also https://stackoverflow.com/a/42660624/104891.

0
Avatar
Permanently deleted user

Hmmm, I don't think it's in a OneDrive folder? As per the filepath included in the error I mention in the OP, the directory is linked from my desktop, not OneDrive:

"Cannot load settings from file 'C:\Users\[redacted]\Desktop\Coding Projects\Courses\Software Construction - Data Abstraction\control-and-data-flow-lecture-starters\HairSalon2Starter\SimpleDebugExercises.iml': File C:\Users\[redacted]\Desktop\Coding Projects\Courses\Software Construction - Data Abstraction\control-and-data-flow-lecture-starters\HairSalon2Starter\SimpleDebugExercises.iml does not exist
Please correct the file content"

0

Does it help if you move it outside of Desktop?

0
Avatar
Permanently deleted user

I tried moving the files to a different location and opening the project from there, but it didn't have an effect.

Here is the root folder I open when I go to open my project:

When I open the project from this folder, this is what my screen looks like:

Note how in the above picture I cannot access the .src folder from the "Project" tab on the top left. I can only access the .src folder if I change the "Project" tab to "Project Files" (I'm unsure what the difference between the two is:

But, of course, all of the files are orange and I can't run them; presumably because the root folders are all messed up. This is what the interface looks like when I go to "Project Structure" to change the root:

I'm not sure that the "SimpleDebugExercises" module is. I didn't name it that. Once I click "Apply" and "OK" this point, it brings me to this screen, where the correct folders are finally showing up in the Project tab. But it's not recognizing the SDK path I configured by default:

I update the SDK definitions to 1.8:

After that, everything looks good. Except now, when I run the main file, I get the error message I mentioned previously.

And what happens if I close the project and re-open it? I'm back to square one:

Sorry for the image-heavy post, but I felt this might help get us to a solution quicker. Any ideas?

0

Check idea.log for errors: https://intellij-support.jetbrains.com/hc/articles/207241085 . It looks like IDE is not able to save files. It can be file system/permissions issue.

0
Avatar
Permanently deleted user

Alright, here's something weird. When I open the project from one folder above the folder I was trying to open it from, it works:

But this is the first time in the course where I've had to open the project at this level. It's a cumbersome solution, because it concurrently opens up a bunch of side files I don't want to work with. Notice all the extra side files and packages on the left-hand bar:

I'll take this solution for now, but am unsure why I can't just open up the "HairSalon2Starter" folder directly.

0

Perhaps some project archetype isn't yet correctly loaded.

Check this article, for Maven projects:

https://stackoverflow.com/questions/4904052/what-does-this-symbol-mean-in-intellij-red-circle-on-bottom-left-corner-of-fil

Also, mark sources directory (src).

0

Please sign in to leave a comment.