user955732
user955732

Reputation: 1370

SET JAVA_HOME in windows bat file not working

why is SET JAVA_HOME in this bat file not overriding the environment variable JAVA_HOME?

someFile.bat

@ECHO OFF
SET JAVA_HOME = Progra~2\Java\jdk1.6.0_23
echo JAVA_HOME: %JAVA_HOME%

OUTPUT

JAVA_HOME: C:\Program Files (x86)\Java\jdk1.7.0_21

Upvotes: 15

Views: 66892

Answers (1)

npocmaka
npocmaka

Reputation: 57322

because of the additional space.Try this to see the value you've set:

echo JAVA_HOME: %JAVA_HOME %

A robust way to set the java_home :

SET "JAVA_HOME=Progra~2\Java\jdk1.6.0_23"

Upvotes: 30

Related Questions