I am trying to compose the classpath for a subsequent java -cp %jarlist%
command. For that I need to concatenate the names of all *.jar
files in a subdirectory lib
.
This is what I came up with so far:
SET jarlist=
FOR %%f IN ("lib\*.jar") DO SET jarlist=%jarlist%;%%f
echo jarlist='%jarlist%'
... but for some reason the strings are not concatenated! At the end the jarlist-variable contains only the name of the last .jar found, e.g. jarlist=';lib\slf4j-all.jar'
If I - instead of concatenating them - echo the individual substrings inside the loop then the individual values look correct:
FOR %%f IN ("lib\*.jar") DO echo %%f
For some reason the concatenation, i.e. the SET jarlist=%jarlist%;%%f
does not work inside the loop. Why? How can I concatenate all the values into one string (separated by ';')?