Download and install ant -- Preparations for mybatis learning notes (1)

Source: Internet
Author: User

Mybatis is another excellent ORM framework. Considering that it may be used in the future, I decided to learn it in advance for the emergency. In order to urge yourself to learn, and to summarize and share with you in a timely manner, I am preparing to write a series of blog posts on mybatis study notes recently. Please pay more attention to, urge, and criticize and correct those who are interested! Thank you!

I did not use any IDE tools in prepare for writing the first Hibernate program by hand and improving the first Hibernate program by hand, the compilation, compilation, and running of two simple Hibernate programs are completed by using the common text editor and related commands. In this way, although it can help you clarify the program running mechanism, the steps are not too cumbersome, so writing a program for a long time will definitely waste a lot of time. Is there an effective tool that can help us with repetitive and tedious work? Yes, ant is an excellent "lightweight" tool that can complete this task. It is lightweight because it is a command line tool that is small and not as huge as IDE such as eclipse. During mybatis learning, I will use ant to manage my projects. Therefore, we will first use two blog posts to introduce the simple usage of ant as a preparation, and hope to help friends who want to know ant. This article describes how to install and configure ant in Windows XP (similar to this in Windows 7 ).

1. Download ant

Ant is a project of Apache (http://ant.apache.org/), the latest version is 1.8.4 (http://ant.apache.org/bindownload.cgi ). We download apache-ant-1.8.4-bin.zip, a common compression format in Windows. Apache recommends that you download and verify the integrity of the file. For this reason, you can use tools such as hashc1c or winMd5Sum to verify the file. On the download page, click "PGP" next to the file to obtain the corresponding verification data. Click "MD5" to obtain the MD5 value of the file. Here, we use winMd5Sum as an example to demonstrate how to verify the integrity of a file. As shown in:


Click "Compare" to Compare two MD5 values. If the two are equal, the following dialog box is displayed:
 
This indicates that the file is not damaged.
Ii. ant installation and configuration
Ant installation is to extract the downloaded compressed package to the corresponding directory. Here I will decompress it to drive D. After decompression, as shown in:



As you can see, this directory name is too long. Therefore, you can change it to a simple directory name based on your interests. Next, you need to configure the environment variables required to run ant. The JAVA_HOME environment variable is required for ant running (the value of JAVA_HOME variable is the JDK installation directory, and D: \ Java \ jdk1.6.0 _ 29 on the author's machine. The configuration method is the same as that of ANT_HOME and CATALINA_HOME) and that of configuring its own ANT_HOME environment variable. The value of this variable is the ant installation directory. Here, of course, it is "D: \ apache-ant-1.8.4. And configure the tomcat CATALINA_HOME environment variables (for the CATALINA_HOME environment variables, right-click "my computer" and choose "properties", "advanced", and "environment variables ", the "environment variables" window is opened. Here, we can configure the required environment variables. Generally, we log on to Windows as "Administrator". Therefore, the upper part of this window is "Administrator user variable ". Click the "new", "edit", and "delete" buttons in the upper part to configure the Administrator environment variables. Windows is designed as a multi-user system. The "Administrator user variable" set here is only valid for Administrator. If there are other users in the system (this should be rare at present) and you want to make the set environment variables valid for all users, you can click "new", "edit", and "delete" buttons in the lower part of the window "system variables" to configure the corresponding environment variables.
Let's configure the Administrator environment variables. Click its "new" button to bring up the "new user variable" window, fill in "ANT_HOME" in "variable name", and fill in "D" in "variable value: \ apache-ant-1.8.4 ", as shown in:

Click "OK.
Run ant. It is ant. bat in the bin directory under the ant installation directory (in this example, D: \ apache-ant-1.8.4 \ bin. Speaking of this, you may have guessed: to run it in any directory, we need to add this bin directory to the path environment variable (about the path environment variable, readers can refer to the author's blog "Explanation of environment variables such as PATH in Windows"). In the "environment variables" window, configure the PATH environment variable for the Administrator user. In the "variables" column, find the PATH variable and click "edit" to bring up the "edit user variable" window. At the end of the variable value, add the following value: % ANT_HOME % \ bin (put ANT_HOME between two percentage signs, indicating that you want to retrieve its value, in this way, the complete path of the bin directory can be automatically calculated. One of the advantages of setting the ANT_HOME environment variable is that if you change the ant installation directory, you only need to modify ANT_HOME. The complete path of the new bin directory can be automatically calculated, you do not need to manually modify the PATH environment variable, which is consistent with the CATALINA_HOME environment variable). Note that the preceding values are separated by semicolons. As shown in:
 
(Note that the JDK bin directory is added to PATH using % JAVA_HOME % \ bin)
All the way to "OK", close all windows, that is, the configuration is complete. Open a command line window (the previously opened command line window cannot take effect) and run the following command: ant-version. You can print the ant version information, as shown in:


Indicates that ant is successfully installed and configured. Run the ant-help command to display the help information of the ant command.
Author: Xiao fan

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.