mvn compile error.

已回答

[code]

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

[/code]

 

This is the output i get when i try to compile using the command in intellij

 

[code]

mvn clean package

[/code]

 

Where is it drawing the directory? I can compile java code no problem.

0

JDK for Maven running in IntelliJ IDEA is configured here:

If you run Maven from the Terminal, JDK/Maven from the PATH will be used.

1

I set it to this in settings, restarted, allowed access due to firewall alert and tried running it in terminal. Still nothing.

 

i echoed %PATH% and this is what i got

C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\apache-maven-3.5.3\bin;

 

I verified that the directory is correct for apache maven. This is done within intellij terminal.

0

Terminal doesn't use any settings in IntelliJ IDEA, it uses the system PATH environment only for both Java and Maven paths.

0

so why am i still getting this compiling issue?

 

My path is correct, i set it to 1.8 as per your picture and yet im still getting a problem...

0

Most likely, `C:\Program Files (x86)\Common Files\Oracle\Java\javapath` points to JRE instead of JDK. Correct your PATH and make sure JDK is first in the list.

1

java path folder consists of java, javaw and javaws executables.

I put maven path in first like this..

 

C:\Program Files\apache-maven-3.5.3\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;

 

i tried running t in the main pom and im still getting the same issue.

0

> java path folder consists of java, javaw and javaws executables.

What is the version reported by these executables? You should install Oracle JDK and put it first in PATH instead. If there is no javac, it's JRE, not JDK.

0

I'm having the same problem. I've set the jdk for importer to my java 8 jdk, the same I use for compiling externally. (It defaults to a JRE!) I set the maven runner to the same thing.

When I open a terminal window, it defaults to java 12. But it should be using the ones in my settings. My project also specifies jdk 8 for both my project and my module language level. My pom.xml file specifies 1.8 for source and target in my maven compiler plug-in. I can't think of where else I should set this. (I have the latest release IntelliJ, 2019.3)

0

Terminal always uses JDK from PATH, not from your IDE project settings.

0

Hi Serge,

Even I am receiving same error, though I changed every setting to JDK 1.8. I've set the jdk importer to my java 8 jdk. 

0

Please report at https://youtrack.jetbrains.com/newIssue?project=IDEA and proivide the outout of `set` (Windows) or `env` (Linux/macOS) command in the IDE terminal. Provide the exact steps to reproduce the issue and the screenshot of the error that you see.

0

What's the solution for this? I have the same issue, perhaps after updating my IntelliJ :(

0

Skalburgi please clarify the problem. Do you have the issue in the IDE or in the terminal? What Java version is configured to run Maven? Is it JRE or JDK?

0

Thanks for responding Serge. I have the issue on my IDE. It started happening all of a sudden today. Its most probably due to IntelliJ update?

1

Does it help if you reinstall the JDK and select the new JDK path as "JDK for importer"?

0

Ahh :( I'll have to look it up..but its an issue with IntelliJ right? because I've been using it as it was for months now

0

So I reinstalled openjdk using brew, and after I did that I have these in the folder /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home

 

0

You need to also check the JDK used for Maven runner here:

If you are running Maven goals from the IDE and have any run configurations created, they may override this setting:

0

Its the same JDK actually, I've got only one version: jdk1.8.0_202.jdk

0

Is there lib/tools.jar and bin/javac in this JDK?

Does the build work from the terminal outside of the IDE?

0

Yes there is lib/tools.jar and bin/javac in this JDK
But the build does not work on the terminal outside of the IDE

0

If it fails outside of the IDE, why do you think the issue with IntelliJ IDEA?

Did you try running with -X option to get more details?

Does it fail for any Maven Java project?

0

Sorry for jumping the gun, it is failing for maven java project. -X did not reveal anything more

0

For one specific project or for any project?

Try with the fresh install of JDK 11 and see if it helps.

0

Ahhh! Our project still uses Java8

0

You can compile for Java 8 using JDK 11.

0

hI! I run into the same problem. 

My maven works fine everywhere except when I try to execute `mvn complile` with Intellij

my setup: 

OS ubuntu 20.04

I install java with SDKMAN. At the moment it's only 11.0.10.hs-adpt


ls /home/ivan/.sdkman/candidates/java/
11.0.10.hs-adpt current

I setup in importing and in runner tabs the same JRE

But for some reason, it doesn't work without the JAVA_HOME env variable ... (see the picture bellow)

is that expected behaviour? 

If so, it might be a bit inconvenient, because the system JDK might differ from the project JDK. 

 

thanks. 

0

Are you getting No compiler is provided in this environment. error when running Maven goal from Maven tool window?

Tried with AdoptOpenJDK 11 set as SDKMAN current JDK and it works for me:

Does it work if you set different JDK for the Maven | Runner | JRE?

Check also that you are not overriding the Java executable in Maven: https://stackoverflow.com/a/20864550/2000323

And check if you have the jdk.compiler jar listed in the JDK configuration which is set for Maven | Runner | JRE:

0

 Are you getting No compiler is provided in this environment. error when running Maven goal from Maven tool window?

yes, and if I run `mvn clean package` with double ctrl button (aka "run anything")

 

 Tried with AdoptOpenJDK 11 set as SDKMAN current JDK and it works for me:

on Ubuntu? 

 

Check also that you are not overriding the Java executable in Maven: https://stackoverflow.com/a/20864550/2000323

Seems like no: 

>>> cat pom.xml | grep maven-compi -a7
</repository>
</distributionManagement>

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

and the compiler is in place

 

I took another notebook with Ubuntu 20.04, and the behaviour is exactly the same, doesn't work without the JAVA_HOME env for Maven Runner.

Thank you. 

0

请先登录再写评论。