• Register
0 votes
632 views

Intellij IDEA on windows 10 is producing the error while trying to run my maven project.

the following output show while running: C:\> mvn -version

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

What would be the proper solution of this problem?

10 7 2
6,060 points

Please log in or register to answer this question.

2 Answers

0 votes

Welcome to kodlogs,

DId you try installing Java Development Kit which is known as JDK at all?

If you did, you can now try setting your system environment variables to achieve the solution.

GOTO Windows Search option and type -

"Edit the system environment variables"

CLICK on "Environment Variables" at the bottom of the popup window.

Focus on System Variables tab. Click on New button -> 

on New System Variable: set

Variable name: JAVA_HOME

Variable value: C:\Program Files\Java\jdk1.8.2\

 

Note that you may face trouble if you include your \bin folder.

 

You can also set it through your command prompt window:

echo %JAVA_HOME% set set JAVA_HOME=C:\Program Files\Java\jdk1.8.2 echo %JAVA_HOME%

 

If that helps upvote my answer. Thanks.

 

11 6 4
34,950 points
0 votes

Solution:

Get rid of the trailing backslash and especially the trailing semi-colon:
C:\Program Files\Java\jdk1.8.0_91

By the way, you can display the current setting with the shorthand of typing "set" at a command prompt followed by the minimal number of characters needed, i.e. on my system:

set j
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_144

Control Panel -> System and Security -> System -> Advanced system settings -> Advanced -> Environment Variables -> New System Variable

unset the JAVA_HOME variable and it worked.

do it through cmd –

echo %JAVA_HOME% set set JAVA_HOME=C:\Program Files\Java\jdk1.8.0 echo %JAVA_HOME%

Make sure that you do NOT have a JRE path, if you have delete it.

  1. Add JAVA_HOME in the System variable. Variable value: C:\Program Files\Java\jdk-10.0.2 (location of JDK without bin)

  2. Add M2 in the System variable. Variable value: C:\dev\maven\apache-maven-3.5.4\bin (location of maven with bin)

  3. Add M2_HOME in the System variable. Variable value: C:\dev\maven\apache-maven-3.5.4 (location of maven without bin)

  4. Add %JAVA_HOME% and %M2% in Path System Variable or C:\Program Files\Java\jdk-10.0.2 and C:\dev\maven\apache-maven-3.5.4\bin --> For windows 10, just add the location. For other version, at the end of the Variable Value field add semicolon then the location Ex: ;%JAVA_HOME%;%M2%

10 6 4
31,120 points

Related questions

1 vote
2 answers 683 views
683 views
Problem: I just completed all the set up for a Java development environment. Downloaded JDK and now trying to set up maven for my project and I am getting this error : nb: java_home should point to a jdk not a jre I couldn’t figure out the solution anywhere online. I am running a windows 10 based OS. Any solution from you is much appriciated. Thanks.
asked Mar 26, 2020 Gavin 15.3k points
1 vote
1 answer 119 views
119 views
Problem: When i am trying run an application in JBOSS 4.0 via eclipse 3.3 i am getting the below exception: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK I had to set the environment ... coming and how to fix. I am able to execute the same application with tomcat 5.0. Can anybody help me to solve out this problem.
asked Apr 8, 2020 LizzyM 6.1k points
0 votes
1 answer 58 views
0 votes
1 answer 37 views
37 views
Problem: I am trying to set up a maven for my project and I am getting this error
asked Feb 17 TeamScript 13.5k points
0 votes
1 answer 3 views
3 views
Problem: I am trying to IntelliJ in Windows 7 32 bit OS based on documentation. I downloaded IntelliJ latest. And tried to install it saying it does not work for 32 bit.
asked Mar 24 ummesalma 25.2k points
0 votes
1 answer 70 views
70 views
Problem the environment variable java_home does not point to a valid jvm installation
asked Feb 9 charles mathews 5.5k points
1 vote
1 answer 3 views
3 views
Problem: I need a help , How I can fix this : perhaps you are running on a jre rather than a jdk maven
asked Apr 4 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 40 views
40 views
I am new to this. I just want to know how to do that? I have a Java project I am working on and I get this error.
asked Dec 3, 2020 TeamScript 13.5k points
0 votes
1 answer 3 views
3 views
Problem: I cannot run my Ant build.xml since I updated to java 1.7.0_52 (or there about). but with this latest jave jdk update somethings different (?). Perhaps JAVA_HOME does not point to the JDK. Any suggestions?
asked Apr 2 ummesalma 25.2k points
0 votes
1 answer 29 views
29 views
Any suggestions?
asked Dec 28, 2020 TeamScript 13.5k points