tpdi
tpdi

Reputation: 35151

Can javac 11 compile binaries/jars that will run on a java 8 JVM?

Can javac 11 compile binaries/jars that will run on a java 8 JVM?

If so, with what flags?

Will setting gradle source compatibility to 11 and target compatibility to 8 work?

Upvotes: 3

Views: 249

Answers (1)

rzwitserloot
rzwitserloot

Reputation: 103018

Yes, but not with source=11 and target=8; only source=8 target=8 will work. You can't use any java features introduced in java9, 10, or 11.

On the command line, the javac option you're looking for is -release 8 (which is like -source 8 -target 8 but shorter and better).

Upvotes: 5

Related Questions