Friday, February 7, 2014

Working MacOS Environment

vim With Syntax Hightligh

By default MacOS does not turn on the syntax highlight. In order to turn on the feature, create a file named: .vimrc and put the following contents in the file:

   filetype plugin indent on
   syntax on

Setup JAVA_HOME

In windows or linux environment, we get used to setting the JAVA_HOME environment variable and set PATH variable. That is easy because we know where is the java installation. For MacOS, the java installation is not so obvious. However, there is a way to find out where is the java installation. The command is under:

    /usr/libexec/java_home

The java_home is a binary utility. You can run it. Here is the result when I run on my macbook pro

.
   [/Users/Gary2013]$ /usr/libexec/java_home 
   /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home
   [/Users/Gary2013]$ 

It is clear that I have install jdk 1.7.0_40. Now we can set the JAVA_HOME environment variable by put the following lines in our .bashrc file:

   JAVA_HOME=$(/usr/libexec/java_home) ; export JAVA_HOME
   PATH=$JAVA_HOME/bin:$PATH
The second line is important. Don't put that like the following:
   PATH=$PATH:$JAVA_HOME/bin
If you do this way, the correct java may not be used. This is because there is java under /usr/bin/java. By put the $JAVA_HOME/bin in the front, we make sure the java version is correct.

No comments:

Post a Comment