A simple notation for adding all the jar files in a directory to Classpath
Reference: http://www.javaeye.com/topic/244?page=2 all the jar files in a directory into the classpath, longer:
Quake Wang wrote code for%%i in ("%hibern8ide%/*.jar") does call "Setclasspath.bat"%%i
Setclasspath.bat:
Code SET _classpathcomponent=%1:argcheck IF%2a==a GOTO gotallargs SHIFT SET _classpathcomponent=%_classpathcomp onent%%1 GOTO Argcheck:gotallargs SET classpath=%_classpathcomponent%;%classpath%
The simple wording is as follows:
Code SetLocal enabledelayedexpansion for%%i in (' Xxx/lib/*.jar ') do SET classpath=! classpath!; %%~FSI Echo%classpath% endlocal
The first sentence: Enable variable delay;
The second sentence: the loop joins the. jar file and joins it in a short path;
For example: C:/Program Files/lib/xxx.jar
Into: C:/progra~1/lib/xxx.jar
The third sentence: Displays the Classpath value after setting;
Restore System Environment settings
Note: The second sentence! classpath! And%%~fsi's writing, especially! classpath!, not%classpath%.
If you want to add the relative diameter to the classpath, you can use
Code for%%i in ('./lib/*.jar ') do SET classpath=! classpath!; %%i
Can.
Question: I don't know. After a relative path, a long file name can also be automatically represented by a short file name: (