Exception while compiling: wrong version 50.0, should be 49.0
Asked Answered
S

5

39

I am working an application with JXL API and when i tried compiling using eclipse IDE, it's working fine and the same is not compiling when i am trying to compile in Command prompt and showing the below exception..

Extract.java:6: cannot access jxl.read.biff.BiffException bad class file: C:\Program Files\Java\jdk1.5.0_01\jre\lib\ext\jxl.jar(jxl/read/biff/BiffException.class)
class file has wrong version 50.0, should be 49.0
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
import jxl.read.biff.BiffException;
                     ^
1 error

EDIT:

I am able to executing using JDK 1.6. Since JDK 1.6 must also be compatible with lower versions, why doesn't it support the class files which were compiled in JDK 1.5.

Starstarboard answered 19/11, 2009 at 20:16 Comment(1)
Thanks all of you for your answers and comments, i've recoverd the problem followed oscar reyes sugesstions.Starstarboard
C
72

The library you're using was compiled with Java 6

Your compiler is Java 5 that's why it doesn't understand that format.

To fix it you have to get a 1.5 version of the library or upgrade your compiler to 1.6 I suggest the later.

Charlottetown answered 19/11, 2009 at 20:27 Comment(1)
Oh, that's no mystery - eclipse ships with it's own compiler so you don't even need a jdk. And that compiler is Java6 compliant :)Wallache
Y
3

Per http://www.jnode.org/node/2140...

Submitted by Stephen Crawley on Fri, 11/30/2007 - 07:15.

I suspect that you are mixing code compiled with different versions of Java. Class file version 50.0 is used by Java 6.0, and 49.0 is used by Java 5.0.

Try doing a "build clean" to get rid of all existing class files, followed by a regular build.

JNode is being developed using Java 6.0 only. Last time I tried, it didn't build using Java 5.0 (aka 1.5). (It is a problem with the program that builds the JNode boot image.)

Try changing the builder in Eclipse. If you're using 3.4, it's Project - Properties - Java Compiler - Enable Project Specific Settings - Compiler Compliance Level = 1.6. You'll prolly also need to have JRE 1.6 installed, as well.

Yeoman answered 19/11, 2009 at 20:28 Comment(1)
Using mvn clean, helped me to find out the mvn.bat file, which in my case, it was setting its own version of JAVA_HOME.Curbstone
J
1

Check you class path in eclipse and make sure that its the same class path your compiling to in the command prompt, also check your library imports

Jacquie answered 19/11, 2009 at 20:26 Comment(1)
Yeah i have checked out everything, everything is right. But even i am getting the exception.Starstarboard
H
1

It means that, you have compiled that class with Java 6 and trying to execute with Java 5.

Solution :

If your using ant, execute below steps on the project root directory

  1. ant clean
  2. ant deploy

If your using eclipse, just clean the workspace(remove the class files which were compiled with Java6) and build again

Harumscarum answered 29/10, 2013 at 2:4 Comment(0)
K
0

this could be that in you IDE you point to latest version of JDK but when you build your program outside the IDE(maybe with maven) your java_home is the older version to the one on your IDE.

Kail answered 28/3, 2013 at 12:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.