Check if the library will run at a specific Java level

What approach can be used to check library compatibility with a specific version of Java?

Example: the X library was compiled on Java 1.7, so it may not work on Java 1.7 or lower.

Thanks.

+4
source share
2 answers

It is best to check the byte code with a compliance rule that can be applied to your assembly using the maven-enforcer-plugin ...

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.4.1</version>
        <executions>
          <execution>
            <id>enforce-bytecode-version</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <enforceBytecodeVersion>
                  <maxJdkVersion>1.7</maxJdkVersion>
                </enforceBytecodeVersion>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>extra-enforcer-rules</artifactId>
            <version>1.0-beta-4</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
  [...]
</project>
+5
source

compile the version you need:

javac -target ...

see that: How to compile java with support for older versions of java?

jar: Jdepend,

JAR Java

-1

Source: https://habr.com/ru/post/1621120/


All Articles