Pages

Java 7 and Groovy on Mac OS X Mountain Lion

I usually keep all my softwares and SDKs to the latest version but jdk7 was probably amongst the longest resisted update/upgrade. Mostly running groovy, I never got motivated enough to upgrade and then there have been several security and compatibility issues reported by many.

Anyways, today I just thought of doing it, primarily to reap benefits of invokedynamic, the thing I have not even looked at so far. The download was pretty simple in form of a .dmg and then the .pkg installer.

I fired up terminal with to check java and viola:
[~]
kunal@kaydee $ java -version
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

The second natural thing was to just verify groovy, but what the heck, the JVM version I see is:
[~] 
kunal@kaydee $ groovy -version
Groovy Version: 2.0.6 JVM: 1.6.0_37 Vendor: Apple Inc. OS: Mac OS X

Apparently Java 7 got installed at
/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/

But the one available to groovy was something else:
[~]
kunal@kaydee $ groovysh
Groovy Shell (2.0.6, JVM: 1.6.0_37)
...
groovy:000> System.properties["java.home"]
===> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Setting JAVA_HOME Environment variable comes to rescue (in .zshrc or .bash_profile or whatever profile file you use.)
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home"

Reload the iTerm and

[~]
kunal@kaydee $ groovy -version
Groovy Version: 2.0.6 JVM: 1.7.0_11 Vendor: Oracle Corporation OS: Mac OS X


My ZSH theme

I was initially hesitant to make the move from bash to ZSH. But thanks to oh-my-zsh now I am just loving it. To spice up the terminal prompt it has a provision of themes (unlike PS1 environment variable in bash).

I looked around for themes and there are many great themes available in the oh-my-zsh repo. But I still wanted to customize the prompt a bit so I went ahead and created my own them called kaydee which looks something like this


It starts with a sweet (but unnecessary) apple, followed by current directory path and then git status.
Then the prompt comes on a new line preceded by username and hostname.


It leaves a blank line between last command's output and the prompt and the colors make this line stands out on black background screen and all user typed commands start at same vertical column (irrespective of what directory you are in), so that while scrolling you can keep eyes fixed and locate commands easily.


You can fork/clone my repo or just copy this theme to spice up your terminal.



Reverse scroll mouse and natural scroll Trackpad on Mac

I frequently connect an external Monitor, a mac keyboard and a (non-mac) mouse to my MacBook Pro while code pairing. I love the natural scroll direction on trackpad but not so for the mouse scroll wheel. I happy to live with regular direction for scroll for a mouse.

Unfortunately, Mac OS X (Lion, Mountain Lion) does not allow such setting out of the box. There is a nice utility app called Scroll Reverser, just a few KBs in size, which can do it for you.



With the config shown in the screenshot above, you can set natural scroll for Trackpad and the reverse scroll (which we are used to) for mouse.