Alice52 / java-ocean

java-tutorial .We intend to explain Java knowledge in this repository.
MIT License
0 stars 0 forks source link

[maven] switch JDK version #98

Closed Alice52 closed 3 years ago

Alice52 commented 4 years ago
  1. delete java.exe, javaw.exe, javaws.exe in follow directory

    • JDK11: default no jre, need run follow command ro generate jre

      bin\jlink.exe --module-path jmods --add-modules java.desktop --output jre
    • JDK10: C:\Program Files (x86)\Common Files\Oracle\Java\javapath

    • JDK8: C:\Windows\System32

  2. switch in pom.xml

    <!-- method1 -->
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <!-- method1 -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>10</source>
                    <target>10</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
  3. use JDK 10 as project SDK in IDEA

  4. choose 10 as project language level in IDEA

  5. choose compile SDK in IDEA


reference

  1. https://blog.csdn.net/fangside/article/details/100024467
  2. https://blog.csdn.net/qq_34216875/article/details/78861768