Failed to execute maven-compiler-plugin: 3.6.1: testCompile when using java 9

I know that there are many questions with a similar error. I would appreciate first of all that the duplicate takes into account that this only happens with Java 9.

I have java 9 installed

C:\_pocs\ws_j9\java9-http-client>java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

C:\_pocs\ws_j9\java9-http-client>echo %JAVA_HOME%
C:\Program Files\Java\jdk-9.0.1

To make a simple example, if I download a very simple example https://examples.javacodegeeks.com/core-java/java-9-httpclient-example/ and I try /

mvn clean install package -e

[ERROR] Failed to parse module-info:
[ERROR] With qdox: null
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.925 s
[INFO] Finished at: 2018-01-01T23:43:32+01:00
[INFO] Final Memory: 13M/44M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:testCompile (default-testCompile) on project http_client: Execution default-testCompile of goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:testCompile failed: Failed to parse module-info -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:testCompile (default-testCompile) on project http_client: Execution default-testCompile of goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:testCompile failed: Failed to parse module-info
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.javacodegeeks.java9</groupId>
    <artifactId>http_client</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Java9HttpClient</name>
    <description>Java Http Client example</description>
    <properties>
        <java-version>1.9</java-version>

        <maven-compiler-plugin-version>3.6.1</maven-compiler-plugin-version>
        <maven-shade-plugin-version>3.0.0</maven-shade-plugin-version>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin-version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>${maven-shade-plugin-version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                    <verbose>true</verbose>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.javacodegeeks.java9.http_client.Main</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

, . , , , Java 9 : Eclipse Java 9. Java 9 Eclipse Oxygen, "No repository, http://download.eclipse.org/eclipse/updates/none". mvn Java 9 ( Java < 1.8:

    <properties>
        <java-version>1.9</java-version>
...
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                    <verbose>true</verbose>
                </configuration>
            </plugin>

straich .

, Java 9 , , , . - , - " -", , .

- , , . , , Eclipse Oxygen, Java 9, .

  • Edited

Eclipse, Windows 24 :

Eclipse Java EE IDE -.

: Oxygen.2 Release (4.7.2) : 20171218-0600

, 1.9 9, , Java 9. , :

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.542 s
[INFO] Finished at: 2018-01-02T05:19:30+01:00
[INFO] Final Memory: 9M/30M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project http_client: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

, :

+6
2

, / module-info.java, . (, src/main/java)

, 3.7.0 maven-compiler-plugin, module-info. [, , .]


, Java, release :

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.7.0</version>
    <configuration>
        <release>8</release>
        <verbose>true</verbose>
    </configuration>
</plugin>

Java9, Jigsaw, Java Platform Module System (JPMS), , Java 9 , . module-info.class, , .

.


, Eclipse Oxygen Java 9

AFAIK Oxygen (Oxygen.2 ) Eclipse Java9 .


:

+2

jdk . windows-> → Java-> jre, jdk .

0

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


All Articles