after downloaded scala 2.10.2 for windows, and run scala I met such error:
"错误: 找不到或无法加载主类 scala.tools.nsc.MainGenericRunner"
which means "error: can't find or load main class scala.tools.nsc.MainGenericRunner". So I check the scala.bat
for reasons, and I found such function:
:set_home
set _BIN_DIR=
for %%i in (%~sf0) do set _BIN_DIR=%_BIN_DIR%%%~dpsi
echo in set_home: %_BIN_DIR%
set _SCALA_HOME=%_BIN_DIR%..
goto :eof
After this function the _SCALA_HOME become D:\program files\scala\files\scala\bin\..
, which is obviously wrong. Anyway, after setting _SCALA_HOME to be right path the error fixed. However, do any one knows what %~sf0
and %%~dpsi
mean and what this function is really trying to do ?
Thank you!
thank you @gourlaysama
I finally found the real reason:execute the following code and you can see the result is :
for %%i in (%~sf0) do (
echo "%%"i is: %%i
echo sf0 is : %%~dpsi
set _BIN_DIR=%_BIN_DIR%%%~dpsi
)
output:
"%"i is: D:\program
sf0 is : D:\
"%"i is: files\scala\bin\scala.bat
sf0 is : D:\program files\scala\bin\files\scala\bin\
so the malfunction is result from the extra space between program
files
!