How to find java jdk folder and change path variable - maven integration

I have Windows Vista and am trying to install maven and test it. But I realized that I have a problem with JAVA, and I need to solve it first.

I do Start-> Run-> cmd

and type in command line

C:\>mvn clean 

I get the following error

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

So, I say: let it sets the PATH for Java, and I did:

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

Change 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 cmd command:

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

and I understand that the version of Java that is working is not under the directory "C: \ Program Files \ Java"

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 

(I recently downloaded the Eclipse IDE and IntelliJ IDE, and I don't know if these applications come with the JDK).

Where can I find my JDK installation on Windows and set the path in environment variables?

+4
source share
4 answers

Switch to

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

Press new button

give

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

so you set up your java site and try

Also, be sure to run the new command line after making any changes to the environment variables.

+10
source

Eclipse comes bundled with the JDK, I believe you need a separate application to run maven.

My environment variables look like this. JAVA_HOME = C: \ Program Files \ Java \ jdk1.6.0_33 Path = (tied to the end),% JAVA_HOME% \ bin; C: \ Program Files \ Spring Toolbox \ apache-maven-3.0.3 \ bin

This all works, but as you can see, I got maven by installing STS. This is just an eclipse distribution that comes with maven (by the way).

+1
source

You can also install java home from the command line. But this will only work in your session, and it will disappear as soon as you close the command line session. Hope this helps.

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

Late for the game, but run it on the elevated command prompt:

 setx /M JAVA_HOME "path_to_Java" 

This will set the path for your device, not the user. Remove /M to install it only for user account.

The SS64 manual (and setx /? ) Says you should have the /M switch at the end, but my personal experience is that it doesn't always work at the end.

0
source

Source: https://habr.com/ru/post/1444087/


All Articles