File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Class Wrong Version Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Class Wrong Version" Watch "Class Wrong Version" New topic
Author

Class Wrong Version

Sondra Colagrossi
Ranch Hand

Joined: Oct 30, 2002
Posts: 68
I am compiling ( javac-ing ) a file with ANT and I get the following message -
C:\eclipse\workspace\titan\com\titan\cabin\CabinBean.java:6: cannot access java.lang.Object
bad class file: C:\Program Files\Java\j2re1.4.0_01\lib\rt.jar(java/lang/Object.class)
class file has wrong version 48.0, should be 47.0
Please remove or make sure it appears in the correct subdirectory of the classpath.

I suspect this is because javac is finding my 1.4 jdk but should be using my 1.3 jdk. But what I am curious about is the information about the version of java.lang.Object available through an API?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

No, there's no standard API for pulling information out of a class file. There are plenty of 3rd-party tools to do this; see, for example, the BCEL libary.


[Jess in Action][AskingGoodQuestions]
Sondra Colagrossi
Ranch Hand

Joined: Oct 30, 2002
Posts: 68
Thanks for your reply.
So they are violating the ecapsulation of a class file and extracting a private field, is that right?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30


So they are violating the ecapsulation of a class file and extracting a private field, is that right?

Huh?
A .class file is kind of like an ELF or COFF object file. It's got various data in it, some of which has to do with the class the file represents, and some of which doesn't. One such piece of information that "doesn't" is the class file version, which we're talking about here. Another such piece of data is the "magic number" that identifies the file as a .class file -- the hex digits "CAFEBABE" at the beginning of the file.
This has nothing to do with "violating encapsultation." This just has to do with treating a class file as data used by the JVM and examining it as such, like a traditional linker does.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class Wrong Version
 
Similar Threads
Class file version error
WRONG CLASS FILE WHEN COMPILING JSP
debugging with ANT
Jdk1.5 configuration... .Please help
Absent Line Number Information - I'm NOT using Ant