Win a copy of Svelte and Sapper in Action this week 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

how to know the version of java used to create a jar file

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How to know the version of the java used to create a jar file? I know that MANIFEST.MF may contain Created-By field which may tell you. But this is not true all the time. Sometimes Created-By field is not there are sometimes it has some arbitrary value. So anybody has any other suggestion?

Regards,
Litty Preeth
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

I don't think you can determine which Java version that was used to create the jar file, just like you can't determine which Java version was used to compile a class. Why is this information important?

Are you maybe interested in which Java version is needed to run the jar file? That's a different question, though.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Open the jar file and check the Manifest file:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.4.2_12-b03 (Sun Microsystems Inc.)

The last line say java version.
 
Litty Preeth
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf Dittmer,

Yes that is exactly what I want to know... Which version of java is required to run a jar? Is there any way to know this?

Thanks and Regards,
Litty Preeth
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A good indication is the class file version. That is contained in the 7th and 8th byte of a class file. (See http://en.wikipedia.org/wiki/Class_(file_format)#General_layout for details.) So you can unjar the jar file, take one of its class file and examine its 7th and 8th byte. This could also be done programmatically using the java.util.jar classes.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:A good indication is the class file version. That is contained in the 7th and 8th byte of a class file. (See http://en.wikipedia.org/wiki/Class_(file_format)#General_layout for details.) So you can unjar the jar file, take one of its class file and examine its 7th and 8th byte. This could also be done programmatically using the java.util.jar classes.



Your response helped me a lot. Thanks Ulf.
 
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic