41

I am using IntelliJ IDEA, learning Java. All went well until yesterday, when the mentioned error occurred.

I didn't make any changes. I was looking for the solution the following ways:

  1. reboot the pc
  2. restart IntelliJ.
  3. delete the project directory and use another one (both on desktop)

nothing helps. buy running simple hello world method. It keeps showing this error:

screenshot

Is there someone able to help me?

Adam Michalik
  • 9,678
  • 13
  • 71
  • 102
user6479494
  • 1,111
  • 1
  • 8
  • 7
  • Add: I am not using any addon, or "Marven". it simply stops to work. And normally no import should be needed for println method. This error corrupted all my previous learning projects. So it doesn't seems to be local or connect to any single class. – user6479494 Jul 28 '16 at 11:46
  • I am having the same problem... As "workaround" I am using `java.lang.System.out.println()` – D.Kastier Mar 11 '17 at 00:35
  • @D.Kastier ur "workaround" also didn't work for me. –  Jun 18 '19 at 06:04
  • @Prabesh Bhattarai in my case, I found out latter that was an user class also named `System`, there fore caused conflict with the java's `System` class. – D.Kastier Jun 18 '19 at 17:37

8 Answers8

69

ok, is solved.

file -> invalidated caches / Restart

user6479494
  • 1,111
  • 1
  • 8
  • 7
23

One reason for this to happen is if you have print statement somewhere on the body of the class, and not inside a method.

Here is an example:

enter image description here

But if the print is inside a method, it should work fine.

Here is an example:

enter image description here

z atef
  • 7,138
  • 3
  • 55
  • 50
13

I think if you have tried the method above, maybe you can consider where you use System.out.println() because this method should only used in main(String args[]){},the latest version of the Idea is OK. I wish what said can help you.

Shushan
  • 1,235
  • 1
  • 10
  • 15
tom Tao
  • 131
  • 1
  • 2
5

If you have orcale sdk configured as your project sdk there is no way System.out.println can't be found - besides you are using another System.out.

So my guess is that you don't have a proper project sdk configured.

Goto to Project Settings or press Ctrl+Alt+Shift+S, go to Project Settings -> Project and check if your sdk is setup correctly.

Peter
  • 4,752
  • 2
  • 20
  • 32
3

In my case my project was set up to Java 6th and I had installed jre1.8.0_131 which I assume was causing the problem. After changing Java to level 8 problem have been solved.

Press Ctrl+Alt+Shift+s or go to File -> Project Structure -> Project, and set Project Language Level to yours.

Konrad Grzyb
  • 1,561
  • 16
  • 12
2

case 1: if all sdk setup is complete and perfect then file -> invalidated caches / Restart this could work case 2 : if something missing in sdk setup of intelij then goto 1.file->project structure->libraries 2.click on + button 3. add location of lib folder of tomcat directory C:\xampp\tomcat\lib to add lib directory to tomcat

1
import static java.lang.System.out;

Or do you possibly have more than one class named System?

Or possibly this link could be of use to you.

Community
  • 1
  • 1
jrmullen
  • 346
  • 5
  • 21
0

Just make sure that your SDK in the setting of INTELIJI is set up have a look here

I had that problem because I pulled the repository from work where we have java 8, but on my private computer, I have 17..