java classpath 批量设置shell脚本

linuxbash jar文件之间的分隔符是':'

exportJAR_HOME=pathtodirectorywhichincludesjars

forfin$JAR_HOME/*.jar

do

JAR_CLASSPATH=$JAR_CLASSPATH:$f

done

exportJAR_CLASSPATH

#thenextlinewillprinttheJAR_CLASSPATHtotheshell.

echotheclasspath$JAR_CLASSPATH

java-classpath$JAR_CLASSPATHNameoftheprogramme

windowsjar文件之间的分隔符是';'

SETLOCALENABLEDELAYEDEXPANSION

setLIB=xx

setCLASSPATH=.

FOR%%CIN(%LIB%\*.jar)DOsetCLASSPATH=!CLASSPATH!;%%C

echo%CLASSPATH%

相关推荐