Re: How to determine Java bytecode version

From: Anthony Borla (ajborla_at_bigpond.com)
Date: 11/27/03


Date: Wed, 26 Nov 2003 23:11:54 GMT


"Samuel Jackson" <sami_jackson@hotmail.com> wrote in message
news:223bb155.0311251251.2a80c8d6@posting.google.com...
> Howdy,
>
> I'm trying to figure out what bytecode version a given class was
> compiled with. I've tried looking at the actual .class file, but that
> didn't pan out.
>
> Is there a utility to determine versions?
>

Every '.class' file starts off with the following:

* Magic Number [4 bytes]
* Version Information [4 bytes]

A hexdump of a '.class' file compiled with each of the following options
reveals:

javac -target 1.1 ==> CA FE BA BE 00 03 00 2D
javac -target 1.2 ==> CA FE BA BE 00 00 00 2E
javac -target 1.3 ==> CA FE BA BE 00 00 00 2F
javac -target 1.4 ==> CA FE BA BE 00 00 00 30

Perhaps you could use this information to write your own '.class' file
version checking utility, using Java, or perhaps a scripting or shell
language ;) !

I hope this helps.

Anthony Borla

P.S.

If requiring more information just do a Google search for ".class file
format" or "Java Bytecode Tutorial"