Setting Current JDK programmatically on Mac

A few days back I was looking for a way to change the CurrentJDK symbolic link on my Mac. I had found this nice script somewhere (don’t quite remember where). But is is very useful.

#!/bin/sh

cd /System/Library/Frameworks/JavaVM.framework/Versions

CURJDK="`readlink CurrentJDK`"echo Current JDK version: $CURJDK

if [ "$1" == "" ]; thenecho Installed versions:lsexitfi

VERFOUND=`ls | grep $1 | head -n 1`

if [ "$VERFOUND" != "$1" ]; thenBASE="`basename $0`"echo Error: Could not change JDK-- version $1 not installed!echo Run $BASE without arguments to see a list of installed versions.exit 127fi

echo You must now enter your Mac OS X password to change the JDK.sudo ln -fhsv $1 CurrentJDK

Save it as a file name of your choice. I saved it as “SetJDK.sh”. Give it execute permissions, and run the script.

AnyEdit: useful plugin for code formatting in Flex Builder / Eclipse

Over the past few days I’ve been searching for a Eclipse/Flex Builder plugin that would let me trim the unnecessary spaces left at the end of lines in the code that I work on.

I found a very nice extension called AnyEdit that performs the task of trimming extra space very well. I’ve been using it for a few hours now and it’s worked very nicely.

AnyEdit can trim trailing spaces on any text-based file type editable in Eclipse/Flex Builder
Another task that the script performs very well is the ability to convert tabs in to spaces (and vice versa).

It also has some other nice features, like case conversion, chars to HTML entity conversion, etc.
You can download the extension from the AnyEdit site.
It’s a must-have.

Adding the PATH variable on Mac OSX

This is another one of those blog entries where I want to blog for the sake of remembering tedious details…

The issue that I was facing was how to add a directory to the PATH environment variable on my Mac.

I wanted to add a path to MySQL install. So I’ll use that example. The following command in a Terminal window created my .bash_profile file. If the file already exists, it would have added to that file.

echo ‘export PATH=/usr/local/mysql/bin:$PATH’ >> ~/.bash_profile

The PATH information is stored in /Users/username/.bash_profile file.

TODO/FIXME extension for Flex Builder

Found this wonderful TODO/FIXME extension for Flex Builder today that shows TODO/FIXME tasks in the Tasks view — much like what one gets in the Java perspective.

Prior to using this extension, I was leaving all kinds of visual and searchable markers in the code so that I could search for them at a later point of time to finish off tasks or fix issues. But with this extension all that will be a thing of the past!

Thanks to Dirk Eismann for this wonderful extension.

Organizing imports in Flex Builder 2

Today I was working on refactoring code of a large Flex application.

Many files contained lots of imports at the top. I was looking for a quick way to organize my imports.

I did vaguely remember that there was on an option somewhere to organize the imports, but couldn’t remember where to find it! Did all my right-clicks etc., but just couldnt’ see it.

I was almost about to move on, but then I found it!
In Flex Builder, click on Source > Organize Imports to organize imports alphabetically.

Even better, there is shortcut keys for it organizing imports.

On Windows: CTRL + Shift + o

On Mac: Apple + Shift + o.

Keep in mind that that imports can only be organized in this manner in Actionscript files only. (This will not work in MXML files.)
But overall, it works beautifully.