aspose file tools*
The moose likes Beginning Java and the fly likes How to find the jdk version used to compile a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to find the jdk version used to compile a file" Watch "How to find the jdk version used to compile a file" New topic
Author

How to find the jdk version used to compile a file

Maya Dolas
Greenhorn

Joined: Jul 04, 2007
Posts: 26
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


<b><i>Maya</i></b>
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14273
    
  21

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Maya Dolas
Greenhorn

Joined: Jul 04, 2007
Posts: 26
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

Joined: Oct 31, 2008
Posts: 2
maybe you can try "java -version" command in your cmd(windows) or shell(linux).that tells you what your JDK version is!!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
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.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find the jdk version used to compile a file