-1

Can jdk 11 generate java 7 byte code? Normally, yes, but after trying

enter image description here

jar files are generated but looking at the version:

$ javap -v org/iq80/leveldb/DB.class | grep major
  major version: 52

it seems that the java 8 (What version of javac built my jar?) is targeted instead of 7 (which is needed for an android build).

How can I force a build for 7?

Sebi
  • 4,262
  • 13
  • 60
  • 116

1 Answers1

1

I would recommend setting this within your pom.xml or build.gradle.

Maven compiler plugin (see the configuration block):

     <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                <forceJavacCompilerUse>true</forceJavacCompilerUse>
                    <source>11</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

Gradle (anywhere top-level within the script):

java {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_1_7
}

If for some reason you are not using these to build, I would seriously consider switching. See CrazyCoder's comment for an IntelliJ solution.

Vadim Hagedorn
  • 159
  • 1
  • 12