You can use homebrew to download the relevant software, the following specifically about the configuration of the environment:
Install JDK under Mac
VI. bash_profile
Enter I, enter edit mode
Enter the following configuration, where Java_home is your JDK installation directory
Java_home=/library/java/javavirtualmachines/jdk1.8.0_121.jdk/contents/home
classpaht=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export Java_home
Export CLASSPATH
Then press ESC, enter: Wq exit
modifying system files
Cd/etc
Sudo VI Profile
Enter I, enter edit mode
Enter the following configuration, where Java_home is your JDK installation directory
Java_home= "/library/java/javavirtualmachines/jdk1.8.0_121.jdk/contents/home"
Export classpath=.: $JAVA _home/lib: $JRE _home/lib: $CLASSPATH
Export path= $JAVA _home/bin: $JRE _home/bin: $PATH
Then press ESC, enter: Wq exit
Enter source profile to enable files modified as above
Enter Java-version to see if the installation was successful:
Success is as follows:
Java Version "1.8.0_121"
Java (TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot (TM) 64-bit Server VM (build 25.121-b13, Mixed mode)
Install Tomcat under Mac
VI. bash_profile
Enter I, enter edit mode
Enter the following configuration, where Tomcat_path is your Tomcat installation directory
tomcat_path=/users/yingmuxiaoge/apache-tomcat-7.0.75
Export=tomcat_path
Install Maven under Mac
VI. bash_profile
Enter I, enter edit mode
Export m2_home=/users/yingmuxiaoge/apache-maven-3.3.9
Export path= $PATH: $M 2_home/bin
Configuring the Java Development environment under MAC installation