• Register
0 votes
485 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 482 views
482 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 71 views
71 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 28 views
0 votes
1 answer 18 views
18 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 9.7k points
0 votes
1 answer 18 views
18 views
Any suggestions?
asked Dec 28, 2020 TeamScript 9.7k points
0 votes
2 answers 89 views
89 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, 2020 jwilliam 3.9k points
0 votes
1 answer 160 views
160 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
0 votes
1 answer 12 views
12 views
Problem: So I know that I should avoid using globals in the first place because of confusion like this, but if I were to use them, could I use them correctly? (I am trying to call a global copy of a variable created in a separate function.) x = somevalue def func_A ... me i am in a search of answer actually i donot have idea that how to define vaiable globally and how i can edit its value anyone ?
asked Nov 10, 2020 Han Li 710 points
0 votes
1 answer 61 views
61 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, 2020 mphil 2.3k points
0 votes
1 answer 946 views
946 views
Problem: I am very new to Cucumber. Recently I was reworking my project in the Intellij into my modules and suddenly I came across below error: "C:\Program Files\Java\jdk1.8.0_181\bin\java.exe" "-Dorg.jetbrains.run.directory=C:\Users\Raphael\Documents\1_Code Stuff ... guru-pet-clinic" Error: Could not find or load main class cucumber.cli.Main Can some Cucumber expert help me in fixing above error?
asked Jul 27, 2020 Raphael Pacheco 4.9k points