Maven: WARNING Unable to autodetect 'javac' path, using 'javac' from the environment

ID : 274319

viewed : 35

Tags : maven-2maven-3javacmaven-2





Top 5 Answer for Maven: WARNING Unable to autodetect 'javac' path, using 'javac' from the environment

vote vote

98

You will see this error message when Maven is being run using a JRE (Java Runtime Environment) which is a stripped down version of Java that can only execute Java code but can't compile sources.

To fix the warning, install the JDK (Java Development Kit) and set the environment variable JAVA_HOME to the newly installed version of Java.

You can put this into the file .mavenrc if you want; then only Maven will use this version of Java.

vote vote

88

If you're running Maven from Eclipse (e.g. Run As : Maven Install), make sure your environment is configured with correct JRE (you'll need JDK, not JRE). Go to Window -> Preferences -> Java -> Installed JRE. Select JDK if it's there or add JDK if it's not.

vote vote

77

A friend of mine experienced this issue when working on building a Java project in Ubuntu 18.04.

When he runs the command:

maven clean build 

He gets the warning:

[WARNING] Unable to autodetect 'javac' path, using 'javac' from the environment 

And then gets this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project geostore-model: Compilation failure -> [Help 1] 

Here's how it was solved:

The issue was that he did not have javac (Java programming language compiler) installed on his machine. To confirm, we ran the command:

javac --version 

And we got no version output

So we installed the Java development kit that contains javac and all of its dependencies using the command:

sudo apt install default-jdk 

Afterwhich we ran the command javac --version and got the output:

javac 11.0.9.1 

That's all.

I hope this helps

vote vote

65

try to set JAVA_HOME in the MyComputer-->Environment Variable

vote vote

50

sudo yum install java-sdk Centos finds the correct SDK with the -devel sufix

Top 3 video Explaining Maven: WARNING Unable to autodetect 'javac' path, using 'javac' from the environment







Related QUESTION?