1

I am working on something in my Java 8 project and now I need to use a model-class from another jar that is done in Java 11 (but not using modules). I declare the Maven dependency in my pom.xml and see the jar file in my project in IntelliJ. When I try to use the class from the jar IntelliJ tells me it doesn't know it as it's not imported yet, but it knows the path where it is so I can just import it.

But when I import it even with the fully qualified it says "Cannot resolve symbol ".

enter image description here

I already tried to invalidate Cache+Restart or delete the Target folder and clean-install again but nothing helps. IntelliJ just can not find the class.

When I check the classpath of my project the jar-project is also there. There is nothing red or anything.

My guess is that either it is because the Project from the Jar is compiled in Java 11 or that IntelliJ can not find the class because when I open the jar it is a Spring Boot project and the top-level folders are BOOT-INF and META-INF and the class that I am looking for is in "BOOT-INF -> classes -> com -> ...".

I would really love to know why my IntelliJ can not find the class from this Jar. Is it not possible to use a Java 11 Jar in a Java 8 project? Can anybody help me?

Invest
  • 545
  • 6
  • 9
  • 6
    You cannot use a jar file compiled in higher version of java in a project developed in lower version of java. – Sambit Aug 08 '19 at 09:14
  • 2
    Java class compiled with higher version of java can't be used in lower version of java. – seenukarthi Aug 08 '19 at 09:14
  • 2
    Possible duplicate of [How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version](https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi) – seenukarthi Aug 08 '19 at 09:17
  • 2
    Consider this the same as going back in time, and saying to a caveman "OK George, would you mind driving my limo out front?" Java 11 libraries can be used by Java 11 projects and up, not lower. – Stultuske Aug 08 '19 at 09:18
  • Thank you all for your answers, of course this explains it. I just whonder why I could not find this information on the internet after hours of research. Everytime I tried to find a solution all I got was "migration guides from 8 to 11". – Invest Aug 08 '19 at 09:23
  • @Invest - That is a difficult question to answer :-) – Stephen C Aug 08 '19 at 09:54

0 Answers0