I am trying to build a project with Java 1.4.2_08 with Maven2, but I receive an error like: "cannot access ClassName" "Bad class file: C:\Path\to\alibrary.jar (ClassName)" class file has wrong version 49.0, should be 48.0
There has been made sure that the code does not contain any Java 1.5 spesifics.
The alibrary.jar i included in another project which I build with maven2 using Java 1.4.2_08, but I receive no problem there.
alibrary.jar har defined in the MANIFEST.MF a Java 1.5 version (I have no control over this).
My projects must be compiled with 1.4
Joined: Mar 22, 2005
The code of the library may not contain any Java 5-specific code, but if it has been compiled by a Java 5 compiler without specifying Java 1.4 as the target, then the class file version will indicate that it is Java 5 code.
If it's an open source library, see if there's a Java 1.4-compatible version, or build one yourself. Check the "-source" and "-target" switches of javac on how to do that.
If it's a commercial library, then the vendor should be able to supply a 1.4-compatible version.
I am using other jars in my 1.4 project that is compiled with the same 1.5 version withouth Maven complaining about them.
Joined: Feb 04, 2004
If the classes in the jar have been compilled using java version 1.5 then any code compilled using java 1.4 or less will not be able to call any classes in the jar. You need to get a 1.4 version of this jar file.
Joined: Jul 10, 2007
Originally posted by Mark Smyth: If the classes in the jar have been compilled using java version 1.5 then any code compilled using java 1.4 or less will not be able to call any classes in the jar. You need to get a 1.4 version of this jar file.
Yes I can understand that, but some other projects I have "downgraded" to 1.4 also include som external libraries compiled with 1.5 and those do not give the same version error.
The Maven POM has defined maven-compiler-plugin source and target to 1.4 and all dependencies has a scope of "compile". I tried to include the external jar I had trouble with in another project and got the same problem with it.
I just find it strange. I have looked at other jar files that are compiled with 1.5(Defined in MANIFEST.MF) that gives me no trouble. Strange that this one should.