Question

i have Windows Vista and i'm trying to install maven and test it. But i realised that i have a problem with JAVA and i have to solve first.

I do Start->Run->cmd

and i type in the command line,

C:\>mvn clean

i get the following error

ERROR: JAVA_HOME not found in your environment. Please set the JAVA_HOME variable in your environment to match the location of your Java installation

So i say: Let's set the PATH for Java and i did:

Start->Control Panel->System->Advanced System Settings->Environment Variable->System Variables

Edit the PATH variable

C:\Program Files\Java\jdk1.6.0_32;C:\apache-maven-3.0.4\bin;

But then i get the same error when i do:

C:\>mvn clean

Then i typed in the cmd prompt:

  C:\>java -version
  java version "1.7.0_07"
  Java(TM) SE Runtime Environment (build 1.7.0_07-b11)

and i realise that the Java version that is running is not located under the "C:\Program Files\Java" directory

The only JDKs i have are: jdk1.6.0_29 jdk1.6.0_32

Then i did Run->cmd

C:\>where java
C:\Windows\System32\java.exe

(Recently i downloaded IDE Eclipse and IDE IntelliJ and i don't know if these apps come with the JDK).

Where can i find my JDK installation in Windows and set the path in environmental variables?

Was it helpful?

Solution

Go to

 Start->Control Panel->System->Advanced System Settings->Environment Variable->user variables

Click on new button

give the

     variable name : JAVA_HOME
     variable value: C:\Program Files\Java\jdk1.6.0_32

in that way you setup your java home and try

Also make sure to take new command prompt after you did any changes in environment variables

OTHER TIPS

Eclipse comes bundled with a JDK, I believe you need a seperate one to run maven.

My environment variables look like this. JAVA_HOME = C:\Program Files\Java\jdk1.6.0_33 Path = (tacked on the end) ;%JAVA_HOME%\bin;C:\Program Files\Spring Tools Suite\apache-maven-3.0.3\bin

This is all working but as you can see I got maven by installing STS. It's just an eclipse distro which comes bundled with maven (among other things).

You can also set java home from command line prompt. But this will be valid only in your session and it will be gone once you close your command line session. Hope it helps.

set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_33

Late to the game, but run this in an elevated command prompt:

setx /M JAVA_HOME "path_to_Java"

This will set the path for your machine and not the user. Remove /M to have it set just for the user account.

The guide at SS64 (and setx /?) say you're supposed to have the /M switch at the end, but my personal experience is that it doesn't always work at the end.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top