java classpath批量设置shell脚本

时间:2022-01-31 14:43:25

java classpath批量设置shell脚本

 
注意:linux bash jar文件之间的分隔符是':' 
 
export JAR_HOME=path to directory which includes jars 
 
for f in $JAR_HOME/*.jar 
do 
JAR_CLASSPATH=$JAR_CLASSPATH:$f 
done 
export JAR_CLASSPATH 
 
#the next line will print the JAR_CLASSPATH to the shell. 
echo the classpath $JAR_CLASSPATH 
java -classpath $JAR_CLASSPATH Name of the programme 
 
注意:windows jar文件之间的分隔符是';' 
 
SETLOCAL ENABLEDELAYEDEXPANSION 
set LIB=xx 
set CLASSPATH=. 
FOR %%C IN (%LIB%\*.jar) DO set CLASSPATH=!CLASSPATH!;%%C 
echo %CLASSPATH%