Java mac automation-java and Ant environment Setup

Source: Internet
Author: User


This article is intended to help readers introduce how to build a Java and ant environment locally if a test engineer gets a Mac copy

In fact, a few years ago, we also mostly use Windows, and we will be good at using Windows notebook, but since the advent of Mac, Mac has quickly become our technical staff more enthusiastic of a notebook, in addition to loading x, more because it is super similar to Linux system, Support for most of the Linux command line, light appearance and so on, on the other hand, it has a Windows-like screen, so that we can operate as a Windows machine operation of the Linux system, but we have to admit that after using the Mac found a lot of differences with windows , so the purpose of this article is to introduce the approximate method of automating it.

In Windows, the author has described the general configuration and methods, the essence is to set environment variables so that the machine can run smoothly Java and Ant, but in Linux and MAC environment variables are often not exist, then we need to do a different way to do
First input Java -version found that the machine does not have Java
Download Java on Baidu, which version can be determined by itself, to the local, can be compared with the Windows version of JAVAJDK, mainly windows we are common. EXE file on the Mac can not run, so all the files under Java/bin have a certain change
I read the main course of the online mainstream http://blog.csdn.net/vvv_110/article/details/72897142
do the following
1, temporary authorization after opening the terminal, sudo su;
2, enter password (password not shown);
3. Create. bash_profile file, touch. Bash_profile (if there is no new, I do not);
4. Open the. bash_profile file, Vi. bash_profile (can open then new success);
5, enter the JDK file path, the system default is 1.6, my is 1.8, can be configured for two, easy to switch later.
Export PATH
Export java_home=/home/work/zouleiran/jdk1.6.0_45
Export java_bin=/home/work/zouleiran/ Jdk1.6.0_45/bin
Export path= $PATH: $JAVA _home/bin
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/ Tools.jar
Save and exit;
6, read and execute commands in the file, source. bash_profile;
7, enter java-version in terminal, display JDK information, then the configuration is successful.
So you can normally configure the Java environment, but in the author's computer found that the so-called tutorial is not right, the main problem is the 5th step, the essence is our location and the location of the tutorial is very large, the location of the tutorial is/system/library/java this directory, This directory can also be found in practice, but it is always not found


Ah, in fact, if we install Java can be like a window in the selected location, but the Mac version of Java seems to be really not
see a lot of raiders and see the relevant configuration, and finally found itself should be installed in the/library/ The Internet plug-ins/javaappletplugin.plugin/contents/home the bottom, so I changed the configuration to
Export PATH
Export java_home=/library /internet plug-ins/javaappletplugin.plugin/contents/home
Export java_bin=/library/internet Plug-Ins/ Javaappletplugin.plugin/contents/home/bin
Export path= $PATH: $JAVA _home/bin
Export classpath=.: $JAVA _home/ Lib/dt.jar: $JAVA _home/lib/tools.jar
found in the execution of 6th step is still not valid, error
Bash:export: ' plug-ins/javaappletplugin.plugin/ Contents/home ': Not a valid identifier
Bash:export: ' Plug-ins/javaappletplugin.plugin/contents/home/bin ': not a Valid identifier

After the translation found that the Internet plug-ins in the middle of a space caused by, so I changed him to this
Export PATH
Export Java_home=/library/internet\ Plug-ins/javaappletplugin.plugin/contents/home
Export Java_bin=/library/internet\ Plug-ins/javaappletplugin.plugin/contents/home/bin
Export path= $PATH: $JAVA _home/bin
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
After this came into effect, it was hard to find.

Here's a little easier to start configuring Ant,ant's configuration. Go to this place to download ant, Link: https://pan.baidu.com/s/1mjSDsDi Password: z2h1
After downloading, according to the following configuration, modify the local configuration yourself, enter the following in the previous. bash_profile file

Export path= $PATH: $JAVA _home/bin
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export Java_home java_bin PATH CLASSPATH
ant_home=/home/work/zouleiran/apache-ant-1.9.7
Path= $JAVA _home/bin: $ANT _home/bin: $PATH

After the input is completed successfully, run the source again after the bash_profile. Execute ant command and find the error right
BASH:/users/zlr/desktop/apache-ant-1.9.7/bin/ant:permission denied
This problem is bin/ant this thing right, the author in the Desktop under the chmod 777 * command or not, entered the/users/zlr/desktop/apache-ant-1.9.7/bin/after the execution chmod 777 * After finally successfully granted permission

The following is my final, for reference

The final appearance of the most important file Bash_profile file

Java mac automation-java and Ant environment Setup

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.