Maven error :Perhaps you are running on a JRE rather than a JDK?

后端 未结 20 2216
小鲜肉
小鲜肉 2020-11-30 21:32

I\'ve never worked with Maven before and I am following the instructions here. When I run the command

mvn integration-test -Pamp-to-war

It

相关标签:
20条回答
  • 2020-11-30 21:40

    I had the same error and I was missing the User variable: JAVA_HOME and the value for the SDK - "C:\Program Files\Java\jdk-9.0.1" in my case

    0 讨论(0)
  • Add this configurations in pom.xml

    <project ...>
        ...
        <build>
            ...
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                        <fork>true</fork>
                        <executable>C:\Program Files\Java\jdk1.7.0_79\bin\javac</executable>
                    </configuration>
                </plugin>
            </plugins>
        </build>
        ...
    </project>
    
    0 讨论(0)
  • 2020-11-30 21:46

    i am using centos and getting same error when run mvn command with goal, install. After some googling i have found the solution to run following command.

    sudo yum install java-1.8.0-openjdk-devel

    0 讨论(0)
  • 2020-11-30 21:46

    Right click on your project folder (Maven one), select properties and from the properties window, again select Java Compiler and see what is selected against compiler compliance level and make sure that it is the same version as your jre. In my case I had 1.8 but 1.5 was selected against compiler compliance level. After selecting 1.8 the build was successful without this error.

    0 讨论(0)
  • 2020-11-30 21:47

    I was facing the same issue in eclipse maven project, all i did was
    right click on the project
    maven --> update project
    or just press ALT+ F5

    0 讨论(0)
  • 2020-11-30 21:47

    If the above solutions doesn't work then try to place java path before maven in path of environment variable. It worked for me.

    %JAVA_HOME%\bin

    C:\Program Files\apache-maven-3.6.1-bin\apache-maven-3.6.1\bin

    0 讨论(0)
提交回复
热议问题