Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot find symbol "var" in Intellij Idea

Whenever I try to run my application from Intellij Idea I get the following error..

If I build the application via Maven it works fine.

Take a look at my module settings the JDK is v10, the language is v10 as well for both the project and module.

Any idea why this would be happening?

enter image description here

enter image description here

enter image description here

like image 617
benstpierre Avatar asked Aug 24 '19 02:08

benstpierre


People also ask

Can not find symbol var?

The “cannot find symbol” error occurs mainly when we try to reference a variable that is not declared in the program which we are compiling, it means that the compiler doesn't know the variable we are referring to.

Why VAR is not working in Java?

The reason may be you are using an older version of java. In Java 10, the var keyword has been introduced. e.g. instead of doing String str = "Java" , you can now just say var str = "Java" .

What does Cannot find symbol mean in Java?

The cannot find symbol error, also found under the names of symbol not found and cannot resolve symbol , is a Java compile-time error which emerges whenever there is an identifier in the source code which the compiler is unable to work out what it refers to.

Does Java have var keyword?

The var keyword was introduced in Java 10. Type inference is used in var keyword in which it detects automatically the datatype of a variable based on the surrounding context.


1 Answers

I have no idea how this ever got set wrong but I had the Java compiler bytecode version settings set wrong in the IDE preferences...

enter image description here

like image 60
benstpierre Avatar answered Sep 26 '22 12:09

benstpierre