简体   繁体   中英

Make multiplatform project to build and run in JDK 8 and 11

I want to migrate my Maven project to JDK 11. But I want to keep support for JDK 8.

Problems so far are:

  • <maven.compiler.release> is supported since Java 9. How to use it in JDK 11 but ignore it in JDK 8?
  • I'm using Apache HttpClient in Java 8. Java 11 has a new built in HTTP client and Apache HttpClient 4.x has some issues on Java 11. Is there a way to use JDK's HttpClient in Java 11 and Apache's in Java 8?

How to deal with those problems? Is it possible to make a project work in different JDKs like this? Or is the only way to keep the smallest commonality for everything?

If you still have to support Java 8, stay on Java 8. Chances are that you will find more problems when trying to achieve this and it might cost you a lot of time.

When you can get rid of Java 8 support, migrate the whole application once to Java 11 and save your time right now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM