jar_min_java_version
This script will display the minimum Java runtime version necessary for the given JAR file.
The minimum Java runtime version is the determined by evaluating the classes contained in the JAR file: The class with the highest Java (class file) version determines version displayed by this script.
For a multi-release JAR this script will not necessarily report the correct version. |
Usage
$ curl -L -O -s https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-api/5.11.0/junit-jupiter-api-5.11.0.jar
$ scripts/java/jar_java_versions.sh junit-jupiter-api-5.11.0.jar
Java Version: 8; Class File Version: 52
$ jar_is_multi_release junit-jupiter-api-5.11.0.jar
0
$ scripts/java/jar_min_java_version.sh junit-jupiter-api-5.11.0.jar
8
$ curl -L -O -s https://github.com/adoble/adr-j/releases/download/v3.3.1/adr-j.jar
$ scripts/java/jar_java_versions.sh adr-j.jar
Java Version: 5; Class File Version: 49
Java Version: 8; Class File Version: 52
Java Version: 21; Class File Version: 65
$ jar_is_multi_release adr-j.jar
0
$ scripts/java/jar_min_java_version.sh adr-j.jar
21
$ echo $?
100
$ scripts/java/jar_java_versions.sh adr-j.jar 8
Java Version: 5; Class File Version: 49
Java Version: 21; Class File Version: 65
$ echo $?
100
$ scripts/java/jar_java_versions.sh adr-j.jar 21
Java Version: 5; Class File Version: 49
Java Version: 8; Class File Version: 52
$ echo $?
100
$ scripts/java/jar_java_versions.sh adr-j.jar 22
Java Version: 5; Class File Version: 49
Java Version: 8; Class File Version: 52
Java Version: 21; Class File Version: 65
$ echo $?
100
$ curl -L -O -s https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy/1.14.19/byte-buddy-1.14.19.jar
$ scripts/java/jar_java_versions.sh byte-buddy-1.14.19.jar
Java Version: 5; Class File Version: 49
Java Version: 6; Class File Version: 50
$ jar_is_multi_release byte-buddy-1.14.19.jar
1
$ scripts/java/jar_java_versions.sh byte-buddy-1.14.19.jar
Java Version: 5; Class File Version: 49
Java Version: 6; Class File Version: 50
$ scripts/java/jar_min_java_version.sh byte-buddy-1.14.19.jar
6