1

I have this script in BASH (linux) shells script that adds all *.jar files into the classpath automatically. Is there a way to do the in window's batch file or do I have to add all the files manually?

CLASSPATH=.
for file in ./libs/*.jar; do
    CLASSPATH=$CLASSPATH:$file
done 

Thanks!

Daniil
  • 1,398
  • 2
  • 17
  • 28

2 Answers2

1

See BAT file to create Java CLASSPATH

Community
  • 1
  • 1
Sonny Saluja
  • 7,193
  • 2
  • 25
  • 39
0

Use the forfiles command to loop over the file names.

forfiles /M .\libs\*.jar /C "cmd /c set CLASSPATH=%CLASSPATH%;@file"
Sonny Saluja
  • 7,193
  • 2
  • 25
  • 39