This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

How to find the jdk version used to compile a file

 
Greenhorn
Posts: 26
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • 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
  • 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
 
Greenhorn
Posts: 2
  • 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!!
 
Rancher
Posts: 43011
76
  • 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.
 
It's a tiny ad. At least, that's what she said.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!