在Tomcat的发行包中有一个bat文件很有意思.
可以把指定的参数添加到classpath里面.
和bat脚本for一起配合,可以实现自动的把某个目录下的jar包都放到classpath里.
rem ---------------------------------------------------------------------------
rem Append to CLASSPATH
rem
rem $Id: cpappend.bat 301115 2002-08-04 18:19:43Z patrickl $
rem ---------------------------------------------------------------------------
rem Process the first argument
if ""%1"" == """" goto end
set CLASSPATH=%CLASSPATH%;%1
shift
rem Process the remaining arguments
:setArgs
if ""%1"" == """" goto doneSetArgs
set CLASSPATH=%CLASSPATH% %1
shift
goto setArgs
:doneSetArgs
:end
配合for一起用
set CURRENT_DIR=%cd%
set CLASSPATH=.
for %%i in (%CURRENT_DIR%\lib\*.jar) do call cpappend.bat %%i
start java -Duser.dir=%CURRENT_DIR% -cp %CLASSPATH% a.b.c.MainApp