1

I have a jar file in that some features only belong to java 8(for ex lambda expression), so it is compiled in java 8. Same jar has some features belong to both java 7 and java 8. Now i want that when user run this jar in java 7 , java 7 related classes should work as he/she only wants functionality that work on java 7 only. If he/she wants the functionality related to java 8 , he will run it with java 8.

This java 8 compiled jar should not give an error of "Lambda expressions are allowed only at source level 1.8 or above". And i don't want to create separate jars for java 8 and java 7 users.

azro
  • 53,056
  • 7
  • 34
  • 70
Ajay Aj
  • 19
  • 1
  • No you will have to create two jars one for java8 and another for java7 runtime ... please check -source, -target javac options – Shailesh Aswal Sep 07 '17 at 11:18

1 Answers1

2

Unfortunately not, multi-release jars allow this, they are a new feature in Java 9, but multi-release jars do not go back to java 7, however they will work for future java releases.

Multi-release Jars

jrtapsell
  • 6,719
  • 1
  • 26
  • 49