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

后端 未结 20 2219
小鲜肉
小鲜肉 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:59

    Problem statement = No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

    Solution

    Please set the Environment variable like below to solve the issue

    Variable name : JAVA_HOME

    Variable Value : C:\Program Files\Java\jdk1.8.0_202

    Variable name : M2_HOME

    Variable Value : C:\Program Files\apache-maven-3.6.0

    Moreover, Add Java and maven path in "System Variables" like below:

    1. C:\Program Files\Java\jdk1.8.0_202\bin
    2. C:\Program Files\apache-maven-3.6.0\bin
    0 讨论(0)
  • 2020-11-30 22:00

    I've been facing the same issue with java 8 (ubuntu 16.04), trying to compile using mvn command line.

    I verified my $JAVA_HOME, java -version and mvn -version. Everything seems to be okay pointing to /usr/lib/jvm/java-8-openjdk-amd64.

    It appears that java-8-openjdk-amd64 is not completly installed by default and only contains the JRE (despite its name "jdk").

    Re-installing the JDK did the trick.

    sudo apt-get install openjdk-8-jdk
    

    Then some new files and new folders are added to /usr/lib/jvm/java-8-openjdk-amd64 and mvn is able to compile again.

    0 讨论(0)
  • 2020-11-30 22:00

    For me, it worked like following. Please look at JAVA_HOME environment variable, whether it is pointing to JRE or JDK.? If it pointed to JRE, you will face "Perhaps you are running on a JRE rather than a JDK" issue. if so change the path to JDK.

    Modifying like this, it worked for me.

    JAVA_HOME C:\Program Files\Java\jdk1.8.0_31

    0 讨论(0)
  • 2020-11-30 22:01

    I faced the issue even though JAVA_HOME was pointing to JDK. It took time to figure out why it was throwing the exception.

    The issue was I set JAVA_HOME as admin user on my window machine. You need to add JAVA_HOME environment variable pointing to right JDK to your user profile environment variable settings.

    0 讨论(0)
  • 2020-11-30 22:02

    Just adding more details on where to setup. Main reason would be the JAVA_HOME setup in the environment variable should be pointing to correct JDK location.

    1. Check System -> Advance System Settings
    2. Click on Environment variable
    3. Add variable JAVA_HOME -> "C:\Program Files\Java\jdk1.8.0_141;"
    4. Edit "path" -> append %JAVA_HOME%; to the existing text.
    0 讨论(0)
  • In Installed JREs path see if there is an entry pointing to your JDK path or not. If not, click on Edit button and put the path you configured your JAVA_HOME environment:

    Eclipse Path: Window → Preferences → Java → Installed JREs
    
    0 讨论(0)
提交回复
热议问题