No suitable method found for forEach error

Hi everyone,

On GH version 0.9, I am getting an error message from com/graphhopper/routing/, line 333, which says:

error: no suitable method found for forEach(<anonymous IntObjectPredicate<SPTEntry>>)

I know the recommended java version is Oracle’s JDK 9, however for various reasons I need to be on open-jdk-8 on Ubuntu, so I need to be able to compile the code on JDK 8. I also get a similar error from com/graphhopper/routing/lm/ line 778 but these are the only two errors.

My question is how can I change these two code blocks to be compatible with Java 8?

Thanks in advance,

Java 9 isn’t released yet.

GraphHopper requires Java 8 (but it’s compatible with Android Java 7 requirements).

Are you sure your IDE is configured that way?

Hi, I created a bare-bones build environment with Ant (another tool I have to use), that has no Android dependencies for now, I have

<project name="gh" default="dist" basedir=".">
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="dist" location="dist"/>
  <target name="init">
    <mkdir dir="${build}"/>
  <path id="build.classpath">
    <fileset dir="lib">
      <include name="**/*.jar"/>
  <target name="compile" depends="init"
        description="compile the source">
    <javac destdir="${build}" >
      <src path="${src}"/>
    <classpath refid="build.classpath"/>
  <target name="dist" depends="compile" description="generate the distribution">
    <mkdir dir="${dist}/lib"/>
    <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
  <target name="clean"
        description="clean up">
    <delete dir="${build}"/>
    <delete dir="${dist}"/>

Compilation tells me I have /usr/lib/jvm/java-8-openjdk-amd64/jre, which is right.

I took the jar files from maven repositories, and copied them under lib/. The list of jars,


For Java sources, I copied all necessary GH java files related to routing, from core, reader-osm. This is pretty much all I have.

I realize the build approach is somewhat old school, nowadays w/ gradle and maven everything is downloaded, setup for you… unfortunately this is what I need to use :expressionless:

You can check GraphHopper core pom.xml for the dependencies.

Also as seen in root pom.xml can use source / target with 1.7 compatibility.
I think Ant javac task has such parameters too.

Do you run it in command line or within an IDE?
Eventually the easiest way is to open the project with a Maven capable IDE (all are). :slight_smile:

That was it. I had the wrong versions for some jars. Now it compiles. Thanks!