I need to set my classpath using all of the jars in a particular directory. Bash does it as follows:
CP_DELIMITER=;
for j in "$MY_HOME/javalib/*.jar"; do
if [ "$CP" ]; then
CP="$CP$CP_DELIMITER$j"
else
CP="$j"
fi
done
But "for
" works differently in DOS, and essentially sends the command to the shell, but won't preserve the "set" on the variable
set CP=./
for %%j in (%MY_HOME%\javalib\*.jar) do (
set $CP=%CP%;"%%j"
)
When you ask for $CP
outside the for, you only get the last jar file. If you echo inside, you can see that %%j
does have all of the values.
Has anyone found a solution?