• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Litty Preeth
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
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • 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.
 
Sachin Kumar
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: 42972
73
  • 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.
 
Arvind Vinay
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!