views:

251

answers:

2

So I re-installed java in a directory that doesn't have any spaces in it, as I was having issues with it before.

Java JDK is installed in:

E:\downloads\java\jdk

I created a User variable:

JAVA_HOME E:\downloads\java\jdk

And my Path looks like:

%JAVA_HOME%\bin;%M2%;

Now opening a NEW cmd prompt:

c:\java
'java' is not recognized...

but echoing works:

c:\echo %JAVA_HOME%
E:\downloads\java\jdk

and so does this:

c:\%JAVA_HOME%\bin\java -version
java version "1.6.0_17"

I am trying to get this to work, so I can then get maven to work as maven is having the same type of issues (I created M2_HOME and M2 and none work).

What exactly am I doing wrong? I am having the exact same issue on my laptop also, both are running windows 7. I must be missing something!

Edit As per your comments, the output of M2 is:

set M2 M2=E:\downloads\java\apache-maven-2.2.1-bin\apache-maven-2.2.1\bin M2_HOME: e:\downloads\java\apache-maven-2.2.1-bin\apache-maven-2.2.1

set PATH

alt text

+1  A: 

Try to append a slash ('\') at the end of the path, like this:

%JAVA_HOME%\bin\;%M2%;

and let me know if it worked.

pajton
nope it didn't, and yes I opened a new cmd prompt :) thanks thought!
Blankman
+3  A: 

As you can see on your capture, %JAVA_HOME% and %M2% are not expanded in your PATH. I suspect that you mixed User variables and System variables. Declare PATH as a User variable like this:

%PATH%;%JAVA_HOME%\bin;%M2_HOME%\bin
Pascal Thivent
yes that works, but I don't understand. Does it pull the system variable PATH into my user variable, so then all sessions have access to the PATH? confused why it worked...
Blankman
@Blankman User variables "see" system variables but the other way around is not true.
Pascal Thivent