Configure Java environment variables under Mac

Source: Internet
Author: User

Method One: Global configuration

#临时提权
sudo su


#输入密码
Vi/etc/profile


#配置JAVA_HOME, where the path is filled out according to your own version

Java_home= "/system/library/java/javavirtualmachines/1.6.0.jdk/contents/home/"

Class_path= "$JAVA _home/lib"
#把JAVA添加到到环境变量PATH中

Path= ".:P ath:java_home/bin"

#设置tomcat的主目录

#CATALINA_HOME = "/usr/local/tomcat" (Tomcat must be installed in advance)

#将JAVA_HOME和CATALINA_HOME设置为环境变量

#export Java_home Catalina_home

Export Java_home


Method Two: Configure for individual users

#以下进入啰嗦模式演示添加jdk7

#下载jdk7的mac版

#官网http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

#下载类似jdk -7U67-MACOSX-X64.DMG, the version number may be updated

#安装好之后, go to the following path to view

cd/library/java/javavirtualmachines/

#再查看你自己安装的版本

Ls

#进入目录 (with more than one version, manually enter the desired version, and only one version, you can press the TAB key to complete automatically after entering the CD space)

CD Jdk1.7.0_67.jdk/contents/home

#复制jdk Home Path, enter PWD in the current directory

Pwd

#把显示出来的路径先复制起来



#进入用户主目录 and see if there is a. bash_profile file

CD ~

Ls-all

#编辑. bash_profile file (no new, Command touch. Bash_profile)

Vim. Bash_profile

#英文模式下, click the I key to enter the edit mode, enter the following content, the path part of their own paste

Export Java_home=/library/java/javavirtualmachines/jdk1.7.0_67.jdk/contents/home

#输完后, press ESC, and then press the colon (shift+;), enter Wq to save



#重启一下终端, enter

Java-version

#看到有显示就完成了

Update file

source. bash_profile

Configure Java environment variables under Mac

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.