kevin
kevin

Reputation: 67

Why the JDK Version in MANIFEST.MF and class file is different

I built my project(JDK version 1.7) with Jenkins (version 2.164.1 with JDK 1.8)

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

then I got a jar file, when I unzip the jar file and vim the MANIFEST.MF

Build-Jdk:1.8.0_131

then I run

javap -verbose MyClass.class | grep "major"
major version: 51

the class file JDK version is 1.7

My project need to run with JDK1.7,is there a trouble with this?

Upvotes: 4

Views: 3956

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35853

To add Eugene's comment:

Build-Jdk tells you the exact version of the JDK that you used to compile (in your case, this is the 1.8.0_131). This JDK can build code with various compatibility levels. These levels are configured in the maven-compiler-plugin. So you build a Java 1.7 compatible code with Java 1.8, which is probably exactly what you want.

You may ask what the Build-Jdk version is for: It helps to you to track down problems that might come from bugs in the JDK or other incompatibilities.

Upvotes: 4

Related Questions