nabayram
nabayram

Reputation: 271

Why are my classes marked in red in IntelliJ IDEA

I have some Java classes which are marked in red in project view, but IntelliJ IDEA shows no errors and it can run properly. What can be the problem?

screenshot

Upvotes: 22

Views: 52808

Answers (4)

WebComer
WebComer

Reputation: 1181

Sometimes files are being marked as red because of inconsistence in project settings and build files. Recently I've checked out some project. The project look well and compile well, but all class names in the code were red. The IDE felt well all the modules paths and even hinted class names, which on been agreed turn red immediately.

When inspected, the ant build model was set to the 1.8 language level, while the default ide module setting was 14. When I set module language setting level to 8, all the red highlight disappeared. So I believe language level to be checked to match everywhere in your project.

Upvotes: 0

Matt
Matt

Reputation: 13943

It means that the files exist locally, but are not in the repository, and are not scheduled for addition. With other words, the files are not under version control. There is not really a problem since the files can just be added to the VCS if desired. This can be done using Add to VCS from the context menu or the shortcut ⌥⌘A (Mac) or Ctrl+Alt+A (Windows).

See File Status Highlights in the official documentation of IntelliJ IDEA for other colours and their respective meaning. See Manage files under version control for how to put the files under version control.

Upvotes: 38

Konstantin Pribluda
Konstantin Pribluda

Reputation: 12367

They are not added to version control repository. Select them, and then CTRL-ALT-A ( or menu via right click ) will add them. Green means there are changes needed to commit

Upvotes: 5

Maleehak
Maleehak

Reputation: 801

Click File -> Synchronize, and IntelliJ should see that everything is okay again.

If that doesn't work, IntelliJ's caches might be corrupt.

Clicking File -> Invalidate Caches and restarting the IDE Src

Upvotes: 2

Related Questions