The windows cmd or batch processing command does not support space solution (1) with quotation marks, indicating a complete path, which is often used in many server batch processing such as jboss and tomcat. Set JAVA_HOME = C: \ Program Files \ Java \ jdk1.5.0 _ 12 set EXE_JAVA = "% JAVA_HOME %" \ bin \ java % EXE_JAVA %-version (2) to a short path, I think this is the best solution. Set JAVA_HOME = C: \ Program Files \ Java \ jdk1.5.0 _ 12for % x in ("% JAVA_HOME %") do set JAVA_HOME = % ~ Sxset EXE_JAVA = % JAVA_HOME % \ bin \ java % EXE_JAVA %-version note that in batch files such as run. in bat, the preceding for statement variables have two %%%. For % x in ("% JAVA_HOME %") do set JAVA_HOME = % ~ Sx (3) if you only want to get a short path with a fixed space, there is a shortcut: Use cmd to locate a directory, enter debug to start x86 virtual mode debugging, and then quit will launch, then the cmd path becomes a short path.