Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to find the jdk version used to compile a file

 
Maya Dolas
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing with the exception java.lang.UnsupportedClassVersionError. I am aware of the cause of it. However would like to know if there is any option which can tell me which JDK version was used to compile the file
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no really easy way to find out, but the UnsupportedClassVersionError should be saying what version it found.

You can find a list of Java class file versions in Wikipedia:

50 = JDK 6
49 = JDK 5
48 = JDK 1.4
47 = JDK 1.3
46 = JDK 1.2
45 = JDK 1.1

Note that older class files work on newer Java versions, but not the other way around.
 
Maya Dolas
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper,

Thanks for your input. As you mentioned there is a way for determining the jdk version but a tedious one, could you give some idea how to go about that so that i can work on same
 
jaywee
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe you can try "java -version" command in your cmd(windows) or shell(linux).that tells you what your JDK version is!!
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As that Wikipedia article explains, the version number Jesper mentioned is contained in bytes 7 and 8 of a class file. But it shouldn't be necessary to look at the file contents: the error message should tell you which class version was found; with that number and the table Jesper posted you can determine which JDK version is needed.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic