Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lambda expressions are not supported at this language level IDEA

I'm trying to create my first fxml java project and at the initialising stage I'm trying to set cell value factory for the table columnt, for example

      @FXML
        private void initialize() {
        agentId.setCellValueFactory(cellData -> cellData.getValue().getIdProperty());
       .....}

and this is underlined red and gives an error that mentioned in title. Changing language level in project structure gives no effect. What else may be the reason of error?

UPD: I've found that it is nesessary to install java with lambdas that is not included to the official release. I did it and nevertheless it didn't help. I've downloaded it here

like image 390
Nikitin Mikhail Avatar asked Apr 28 '15 13:04

Nikitin Mikhail


People also ask

Does Java 11 support lambda expressions?

Java 11 allows to use var in a lambda expression and it can be used to apply modifiers to local variables.

Does Java 7 support lambda expressions?

Retrolambda provides a backport of Lambda expressions for Java 5, 6 and 7. From the Retrolambda documentation: Retrolambda lets you run Java 8 code with lambda expressions and method references on Java 7 or lower. It does this by transforming your Java 8 compiled bytecode so that it can run on a Java 7 runtime.

Which of the following is are not valid lambda expressions?

Option A is the invalid lambda expression because the type is specified for the variable j, but not the variable k. The rest of the options are valid lambda expressions.

Is Java 8 lambda expression correct?

Q 6 - Which of the following is correct about Java 8 lambda expression? A - Using lambda expression, you can refer to final variable or effectively final variable (which is assigned only once).


2 Answers

I had to do a few things to get rid of this problem.

  1. File > Project Structure > Project > Project SDK: Change it to Java 1.8.XX
  2. File > Project Structure > Project > Language Level: SDK 8 (in my case SDK default was already 8)
  3. File > Project Structure > Modules > Sources > SDK 8 (in my case SDK default was already 8)
  4. File > Settings > Build, Execution, Deployment > Compiler > Java Compiler > Project bytecode version > 1.8
  5. File > Settings > Build, Execution, Deployment > Compiler > Java Compiler > Per-module bytecode version > Target bytecode version > 1.8

That should do the trick.

like image 198
Fernando Raposo Avatar answered Sep 21 '22 16:09

Fernando Raposo


the answer is the following: I had to change the language level not only in project structure->project but in project structure-> modules too.

like image 35
Nikitin Mikhail Avatar answered Sep 22 '22 16:09

Nikitin Mikhail