Skip to content

Instantly share code, notes, and snippets.

@javadabadoo
Created May 9, 2015 05:16
Show Gist options
  • Save javadabadoo/73cffe57bb8a537b58dd to your computer and use it in GitHub Desktop.
Save javadabadoo/73cffe57bb8a537b58dd to your computer and use it in GitHub Desktop.
Gets JDK version used on each JAR file stored in $LIB_HOME
#!/bin/bash
LIB_HOME=/path/to/lib/*.jar
version['45.3']=1.1
version['46']=1.2
version['47']=1.3
version['48']=1.4
version['49']=5
version['50']=6
version['51']=7
version['52']=8
for JAR_FILE in $LIB_HOME
do
echo "- $(basename $JAR_FILE)"
rm -rf jar_content
unzip -qq -n $JAR_FILE -d jar_content
v=$(javap -verbose $(find . -type f -name '*.class' | sort -n | head -1) | grep major | tr -d '[a-z] +:')
echo -e " Java ${version[$v]}\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment