Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 269
user955732 Avatar asked Nov 26 '13 10:11

user955732


1 Answers

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"
like image 158
npocmaka Avatar answered Sep 22 '22 06:09

npocmaka