Cannot refer to the non-final local variable productname defined in an enclosing scope

Probably you are using java 8 and the other computer is using java 7. Java requires references to variables from inner classes to be final variables. Java 8 will make them effectively final if you don’t reassign.

Cannot refer to the non-final local variable productname defined in an enclosing scope
Cannot refer to the non-final local variable productname defined in an enclosing scope

Probably you are using java 8 and the other computer is using java 7. Java requires references to variables from inner classes to be final variables. Java 8 will make them effectively final if you don’t reassign.

Solution

You need to change java 1.7 to java 1.8 in eclipse java compiler.

Select your project –> Right click –> Properties –> Java Compiler

Eclipse Java Compiler
Eclipse Java Compiler

1 Comment

Add a Comment
  1. Thank you so much for the solution

Leave a Reply