Batch and the for loop

Posted by Farid on Stack Overflow See other posts from Stack Overflow or by Farid
Published on 2010-04-30T17:20:13Z Indexed on 2010/04/30 17:27 UTC
Read the original article Hit count: 352

Filed under:
|
|

Hi everyone,

I have a java application launched by a .cmd file. I want to set the classpath of the application through this batch, all the needed jars are into a lib folder.

Here is what I tried :

 set _classpath=.
for %%i in (%1/lib/*.*) do ( set _classpath=%_classpath%;%%i )

Surprisingly, it seems that it does not act as expected. Let's say there is 3 jar in the lib folder :

  • pikachu.jar
  • sonic.jar
  • mario.jar

Here is what happens :

  1. set _classpath=.
  2. set _classpath=.;pikachu.jar
  3. set _classpath=.;sonic.jar
  4. set _classpath=.;mario.jar

Obviously, what I am looking to get is

  • set _classpath=.;pikachu.jar;sonic.jar;mario.jar

Any idea ?

Thanks and regards,

© Stack Overflow or respective owner

Related posts about batch

Related posts about java