Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to tell if a class was compiled for java6?

How can I do to tell if a java class was compiled for use on a java 6 vm?

Is there an easy way?

like image 789
feniix Avatar asked Jun 01 '10 16:06

feniix


2 Answers

It's in the class file format specification. The WP article on the subject includes the current set of version number constants.

like image 85
crazyscot Avatar answered Nov 03 '22 00:11

crazyscot


In unix,

$ javap -classpath <classpath> -verbose foo.Bar \
  | grep -q 'major version: 50' && echo yep || echo nope

thanks @matt b.

like image 44
Kevin Bourrillion Avatar answered Nov 02 '22 23:11

Kevin Bourrillion