Reputation: 403
I'm running IntelliJ IDEA on Ubuntu 18.04. I've just installed Java 11 and have updated my .bashsrc
file to set JAVA_HOME
to the new JDK. In the terminal I can run mvn clean install and it will build my d fine. But in the IntelliJ terminal window, I get the following error when running a mvn clean install
The
JAVA_HOME
environment variable is not defined correctly
This environment variable is needed to run this program
NB:JAVA_HOME
should point to a JDK not a JRE
In the IntelliJ terminal window this is the result of echo $JAVA_HOME
/usr/lib/jvm/java-11
Similarly, this is the result of echo $PATH
/home/myusername/.local/bin:/home/myusername/.local/bin:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:
/usr/local/games:/snap/bin:/usr/lib/jvm/java-11/bin:
/usr/lib/jvm/java-11/db/bin:/usr/lib/jvm/java-11/bin:/usr/lib/jvm/java-11/db/bin
What do I need to do to have IntelliJ's version of maven recognize JAVA_HOME
? I've already set my Project SDK to JDK11.
Upvotes: 3
Views: 11513
Reputation: 41
Go to the Preferences > Build Tools > Maven > Runner
, and set the JAVA_HOME
property manually.
Upvotes: 2
Reputation: 839
you may need to update your "maven-javadoc-plugin" version.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Upvotes: 2
Reputation: 51
I had almost the same issue, except my Java version was shown as 1.8 after typing mvn -v in IDEA, but JAVA_HOME value was empty while it displayed correctly in Linux terminal. I`ve typed the following command in IDEA terminal
export JAVA_HOME=*path to Java 11*
This solved my problem. I think you could try the same without reinstall both Java and Maven.
Upvotes: 2
Reputation: 403
I messed around with this for a couple of hours yesterday but was unable to resolve the issue. In the end, I completely uninstalled both Java and Maven and then reinstalled JDK8 and the latest Maven. This appeared to fix the problem in that IntelliJ's command line was able to locate JAVA_HOME.
Here are the two resources I used to uninstall all Java and then reinstall JDK8, for anyone who is interested.
How to completely uninstall Java
I've yet to reinstall JDK11.
Upvotes: 1