• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding class version

 
surya.raaj prakash
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

When i build my application with ant tool i got a compilation error and how can i find out the class file vesion?
[javac] bad class file: D:\javahack\workspace4\javahack\lib\sanjdk.jar(com/sunn
/xml/XMLDataDOM.class)
[javac] class file has wrong version 50.0, should be 49.0
[javac] Please remove or make sure it appears in the correct subdirectory of
the classpath.
[javac] import com.sunn.xml.XMLDataDOM;
[javac] ^
[javac] 1 error
 
Rob Spoor
Sheriff
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Class version 50.0 means the class has been compiled using Java 6. You are trying to run it with a Java 5.0 JVM though. Either upgrade the JVM to 6, or use the -target flag to compile the class for a Java 5.0 environment.
 
Martin Vanyavchich
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you realy need to find out your class files version, open it with a hex editor. All classes start with CAFE BABE xxxx xxXX. Dont know what bites mean where I put the little x, but the big XX stands for version. It's in hex so 0x31 = 49 version 5.0, 0x32 = 50 version 6.0 ...
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin Vanyavchich wrote:If you realy need to find out your class files version, open it with a hex editor. All classes start with CAFE BABE xxxx xxXX. Dont know what bites mean where I put the little x, but the big XX stands for version. It's in hex so 0x31 = 49 version 5.0, 0x32 = 50 version 6.0 ...


Or javap with the -verbose option.
 
Martin Vanyavchich
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool, didn't know about javap, thank you Jelle.
 
Poobhathy Kannan
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
surya, it good to know how to find the class version.But I doubt that finding the class version in your class file will be helpful for resolving this issue and it is already in the error message given by ant and the class version is 50. you should use the component(sanjdk.jar) compiled with compiler compliance level 1.5, or as Rob suggested upgrade your JVM
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If my Oracle download ever opens (it was so much faster from Sun) I can give you a link to the "javac" tool; there you will find what the options to compile for a particular version are.

Try here and look for the pale blue box with "javac" in, near the top left, or here and "javac" is the top line.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic