A simple notation for adding all the jar files in a directory to Classpath

Source: Internet
Author: User
Tags goto joins

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: (

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.