• Register
0 votes
349 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

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 354 views
354 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 Gavin 15.3k points
1 vote
1 answer 34 views
34 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 LizzyM 6.1k points
0 votes
2 answers 76 views
76 views
Problem : I want to compile a project in Eclipse using the m2eclipse. I set my JDK path in Eclipse as below: Windows-->preferences-->installed jres--> jdk1.7.xx path But this is showing me below error [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ ... BUILD FAILURE [INFO] ------------------------------------------------------------------------
asked Feb 4 jwilliam 3.9k points
0 votes
1 answer 38 views
38 views
Problem : I am beginner to CentOS. I tried executing sudo ./startup.sh in my CentOS, But I am facing the below error: "Neither the JAVA_HOME nor the JRE_HOME environment variable is defined" I have already defined them in my bashrc as shown below: export JAVA_HOME=/home/mphil/New_learning/jdk1.8.0_212 export PATH=$JAVA_HOME/bin:$PATH How to fix this error?
asked Feb 27 mphil 2.3k points
0 votes
1 answer 120 views
120 views
Problem : I'm trying to run Java Applet and every time I try to run program, I got this this error. error: java.lang.illegalstateexception: failed to create a child event loop
asked Oct 23, 2019 peterlaw 6.9k points