Matthias
Matthias

Reputation: 4677

Maven (commandline): No compiler is provided in this environment

Failed to execute goal or.apache.maven.plugins:maven-compiler-plugin:3.1:comple <default-compile> on project google-play-services: Compilation failure

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

This is the result when using the Android SDK Deployer from the commandline in Windows. I added JAVA_HOME C:\Program Files (x86)\Java\jdk1.7.0_45 to my system variables.

Did I configured the wrong parts?

enter image description here

Upvotes: 26

Views: 64557

Answers (6)

1.21 gigawatts
1.21 gigawatts

Reputation: 17850

The java.com download page says "Download Java"

enter image description here

If this is the JRE and not the JDK. This is confusing.

The link downloads as, jre-1234. So this is the JRE.

There seems to be another download on oracles home page (that forces you to login) and one on openjdk.

There is a faq on the openjdk page:

How Do I Download Java JDK?
You can download Java JDK 8 and 11 by scrolling up on this page and selecting the version you need from OpenLogic.

If you type javac in the command line and get the command is not found the java compiler is not installed.

Upvotes: 0

Meriem
Meriem

Reputation: 29

I run my spring boot project in vscode, I stumbled on this same issue. Adding this to my pom solved it

<plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <fork>true</fork>
                <executable>C:\Program Files\Java\jdk-13.0.2\bin\javac.exe</executable>
            </configuration>
        </plugin>

Upvotes: 1

Jlearner
Jlearner

Reputation: 613

While setting JAVA_HOME on windows os use Progra~1 instead of Program files since it has space in between e.g. C:\Progra~1\Java\jdk1.8.0_251

Progra~1 = 'Program Files' Progra~2 = 'Program Files(x86)'

Upvotes: 0

Dherik
Dherik

Reputation: 19110

This error can also happen if you install a new version of JAVA (JRE), because the Java installer change the order of environment variables on Windows.

So, verify the PATH values in the System Variables. If you see the:

C:\Program Files (x86)\Common Files\Oracle\Java\javapath

Or:

C:\ProgramData\Oracle\Java\javapath

On the top of the list, edit the PATH and change the order of the previous paths to stay below to the JDK path variable (per example, C:\Program Files\Java\jdk1.8.0_162\bin).

Upvotes: 33

Kandy
Kandy

Reputation: 1107

Normally this happens, compilation of the source cannot be done from JRE(Runtime Environment) its for running the compiled code.

So first thing should done is validating JAVA_HOME path defined in environment variables.

it should be directed to JDK. eg:

C:\Program Files (x86)\Java\jdk1.8.0_111

Upvotes: 26

Matthias
Matthias

Reputation: 4677

The problem was very easy to solve. I only had to restart the commandline after changing the system variables.

Upvotes: 16

Related Questions