How to scan Java8 code with SonarQube 9.9 LTS

How to scan Java8 code with Maven on SonarQube 9.9 LTS. Shall we need to use both java versions on my machine, then run mvn install using the java 8 and then run the sonarscanner using Java 11?

Take a look at the documentation on Scanner Environment.

If you can’t compile with Java 11 targeting Java 8, yes.