2 years ago

#90405

test-img

cristian

Different result maven and jdk 1.7 vs jdk 1.8

I have a maven module and I have this situation:

  • if I compile the module with jdk 1.7 it will create a jar file and a 'META-INF' folder. But it does not include classes from the module, so in runtime I get the ClassNotFoundException.

  • but, if I compile the same module with jdk 1.8, classes are added to the jar file.

I'll attach a photo to see the result.

I use maven to compile (from terminal, not ide).

This is maven info: Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: C:\development\apache\apache-maven-3.6.3\bin.. Java version: 1.7.0_80, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.7.0_80\jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "windows"

And this is java info: java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode) and Java 1.7.0_80 and this is an example of a pom.xml.

And this a pom example:

hermes-maven-plugins hermes 4.3-SNAPSHOT

<modelVersion>4.0.0</modelVersion>
<artifactId>hermes-css-generator-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>

<name>css-generator Maven Mojo</name>

<dependencies>

    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-plugin-api</artifactId>
        <version>2.0</version>
    </dependency>

    <dependency>
        <groupId>hermes-front</groupId>
        <artifactId>hermes-front-commons</artifactId>
        <version>${hermes.version}</version>
        <scope>compile</scope>
    </dependency>

</dependencies>
None of the classes I have in module hermes-front are included in the compiled jar. But using java 8 I do have all this files included in jar. Java 8 info is:

java version "1.8.0_231" Java(TM) SE Runtime Environment (build 1.8.0_231-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

Does anyone has an idea why this could happen?

I need to use the jdk 1.7 version until this jdk is updated in pro environment.

Thanx a lot. enter image description here

java

maven

java-8

java-7

0 Answers

Your Answer

Accepted video resources