• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Regarding class version

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 22850
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ...
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool, didn't know about javap, thank you Jelle.
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 80749
486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic