Add Java environment variables under Mac
Method One: Global configuration
1234567891011121314151617 |
#临时提权sudo su #输入密码vi /etc/ profile#配置JAVA_HOME, where the path is filled out according to your own versionjava_home="/system/library/java/javavirtualmachines/1.6.0.jdk/contents/home/" Class_path="$JAVA _home/lib" #把JAVA添加到到环境变量PATH中PATH=".: $PATH: $JAVA _home/bin" #设置tomcat的主目录#CATALINA_HOME = "/usr/local/tomcat" (Tomcat must be installed in advance)#将JAVA_HOME和CATALINA_HOME设置为环境变量#export java_home catalina_homeexport java_home |
Method Two: Configure for individual users
123456789101112131415161718192021222324252627282930 |
#以下进入啰嗦模式演示添加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 viewCD /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 directorypwd#把显示出来的路径先复制起来#进入用户主目录 and see if there is a. bash_profile fileCD ~ 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 pasteexport java_home=/Library/JAVA/javavirtualmachines/jdk1. 7.0_67.JDK/Contents/Home #输完后, press ESC, and then press the colon (shift+;), enter Wq to save#重启一下终端, enterjava -version #看到有显示就完成了 |
MAC Java environment variable settings