16

Im trying to use a HashMap but getting the error:

"The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files"

I'm using JDK 8 along with Eclipse.

Anybody know why?

My code

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Map;
import java.util.HashMap;

public class Analyser {

    public void analyse() throws FileNotFoundException {

        HashMap<String, Integer> candyMap = new HashMap<String, Integer>();

        BufferedReader br = new BufferedReader(new FileReader("Candy.txt"));

        for(String s=br.readLine(); s!=null; s=br.readLine()) {
            System.out.println(s);
        }       

    }
}
Sergey Ponomarev
  • 2,947
  • 1
  • 33
  • 43
Dom Shahbazi
  • 720
  • 2
  • 10
  • 25

1 Answers1

20

This was fixed by changing my Eclipse IDE version from indigo to luna. Luna comes with support for Java 8 so all issues have now been resolved.

Dom Shahbazi
  • 720
  • 2
  • 10
  • 25
  • Thanks! Made my day! Spent hours trying to figure out same problem with project imported from kepler to helios – Ruturaj Patil Apr 17 '15 at 03:28
  • I installed Mars, that too solved the issue. – Siddharth Feb 17 '16 at 08:11
  • Combination of Mars , Java 8 , tomcat 8.0 working on one machine and not working on another machine – swapnil7 May 10 '16 at 12:28
  • I had that problem when building a Maven project. It was caused by JAVA_HOME pointing to the JRE contained in JDK8. Setting JAVA_HOME to JDK8 directly solved the issue. `maven --version` shows the Java settings of Maven. Perhaps there is a similar mismatch in Eclipse. – user2043553 Oct 17 '17 at 13:01