TurboManage

David Chandler's Journal of Java Web and Mobile Development

  • David M. Chandler


    Web app developer since 1994 and former Developer Advocate with Google now residing in Colorado. Besides tech, I enjoy landscape photography and share my work at ColoradoPhoto.gallery.

  • Subscribe

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 241 other followers

  • Sleepless Nights…

    July 2010
    S M T W T F S
    « May   Aug »
     123
    45678910
    11121314151617
    18192021222324
    25262728293031
  • Blog Stats

    • 857,971 hits

Configuring Eclipse on a Mac

Posted by David Chandler on July 8, 2010

I’m attempting to make the switch from Windows to Mac courtesy of my new employer (I’m pleased to be working with the GWT team at Google). While I very much like my shiny new MacBook Pro, I simply don’t get all the Mac hype. The biggest problem has been that I’m a keyboard person, and Macs are for mouse people. Most Windows keyboard shortcuts have Mac equivalents, but they’re just different enough to make for a bit of a learning curve, like Ctrl+arrows instead of Home and End. Thankfully, many keys can be remapped via System Preferences, but I haven’t found a way to map the editing keys yet (anyone?). My biggest annoyance is that holding down the Alt key doesn’t bring up menu shortcuts as on Windows. That makes going to Run | External Tools a real pain in Eclipse. Alt+R, E becomes Ctrl+F2,R,R,down arrow,E. Runner up annoyance is that there’s no way to use the keyboard to click “No” in a confirmation dialog.

At any rate, here are a few notes for other Eclipse users making the switch from Windows to Mac.

The first thing is to make the fonts readable. This is not necessarily a Mac thing, but the system font does seem especially small. In Eclipse preferences (Command+comma in most apps on the Mac–nice), I bumped up the font size (General | Appearance | Colors and Fonts | Basic | Text Font). This increases it for the Console window, but some plug-ins seem to use the system font instead, which leaves these “over the hill” eyes squinting at logs. Which, in turn, brings us to an almost-unbelievable discovery: you can’t change the system font on a latest, greatest Mac (OS X 10.6.3)! Problem still unsolved.

Now, time to move over my Eclipse external tools configurations from Windows. The external tools config to launch Finder in the selected project directory is very cool, but far from obvious. In the Run | External Tools | Configuration… dialog, enter the following information:

Location: /usr/bin/open
Working Directory: ${project_loc}
Arguments: .

This corresponds to typing “open .” in a Terminal window, which launches Finder in the current directory. Now if I could just configure a shortcut key to launch Terminal so I don’t have to click the icon in the dock every time… See Finder toolbar button to open Terminal to go the other way.

You can also create an external tool to launch Terminal in the selected project directory. Well, almost. To launch Terminal, you have to key into the Location field the full path /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal; however, it always opens in your home directory, even if you set Working Directory to the ${project_loc} variable. That defeats the purpose of this particular tool launcher. Fortunately, xterm is a little smarter, so the following settings work:

Location: /usr/X11/bin/xterm
Working Directory: ${project_loc}
Arguments: (none)

Unfortunately, the default xterm font is miniscule.

Fortunately, you can put the following lines in ~/.Xdefaults to increase the default font size:

XTerm*font:     *-fixed-*-*-*-20-*
XTerm*boldFont: *-fixed-*-*-*-20-*

Now we’ve replicated the command prompt external tool from Windows Eclipse, but unfortunately, it’s a pain to get to the Run | External Tools menu via the keyboard. So we might as well punt and make it even easier with the mouse. thanks to this nifty open source plug-in for Eclipse. Once you’ve installed the plug-in, simply right-click on a project and select “Open in Terminal” to open a new xterm. Someone should contribute “Open in Finder” to that project, too.

Most keyboard shortcuts on Windows map directly to the map in the standard way; that is, you press the Command (Apple) key on the Mac instead of Ctrl on the PC. One notable exception is Ctrl+Space, which is identical on the Mac. Command+Space would be more consistent; however, this brings up the Spotlight search tool on the Mac. Since I’d rather have Ctrl+Space work in Eclipse where my muscle memory is expecting it, I swapped these keystrokes in Eclipse Preferences and Mac System Preferences. Another alternative is to disable Spotlight in favor of Google Quick Search Box.

Eclipse on Mac tricks welcome in the comments. No flames, please.

Advertisements

7 Responses to “Configuring Eclipse on a Mac”

  1. Stephen said

    Agreed on not getting the Mac hype.

    FWIW, after being quite comfortable on Windows for years, I joined a Mac shop but was able to dodge OSX by opting for Ubuntu. I really did try OSX but just couldn’t get used to it. I like Ubuntu–it seems more Windows-ish (in a good way) to me.

    Congrats on the move to Google–that seems worthy of its own blog post. 🙂

  2. Jim Smart said

    To get better keyboard control on your Mac, you should maybe take a look at Quicksilver – I use it all the time: invoke it with cmd-space, type the first letter or two of the app you wish to launch, hit return. It’s really quick. It can do much more than that, but that’s how I use it 99% of the time (I’ve disabled the shortcut to Spotlight). If it doesn’t come up with the app you want to launch, cursor down until you find it, hit return, that teaches it that that’s what you want for next time. I’ve also configured my Quicksilver so that the default action is ‘compose email’ when I pull up a contact – as I write a lot of emails at times, that helped my workflow (probably no use if you use web-based email).

    There’s a tool called DoubleCommand, which is primarily for remapping the infrequently used ‘enter’ key (between the cursor keys and the right-cmd key – it has a funny little ‘up arrow’ on it – although your keyboard may be different to mine?) to be more useful. That tool has an option for ‘PC style home and end keys’ – I don’t know if that will give you the behaviour you want?

    Regarding getting to the External Tools menu in Eclipse: you can assign a keyboard shortcut to open the external tools launch configuration dialog within Eclipse’s prefs (Prefs->General->Keys) – by default it’s not mapped to anything – and you can select and run an external tool from that big ugly dialog box (maybe not the cleanest of solutions, but it works for me). Again, I don’t know if that helps in your case?

    Pressing escape cancels most confirmation dialogs (although I do note, for example, that this doesn’t work on the warning dialog presented when I try quitting Eclipse and still have external tools still running – it just quits anyhow – I think that’s most likely to be an Eclipse bug?). Obviously, in some cases cancelling a dialog isn’t the same as selecting the No option, but most dialogs also allow you to hit the tab key to select which button has focus, and then hit space to select it.

    I like to use iTerm as my terminal on the Mac – setting the working directory in Eclipse’s external tools config didn’t do anything for me, but instead I set it up like this:-

    Location: /Applications/iTerm.app/Contents/MacOS/iTerm
    Working Directory: (leave blank)
    Arguments: ${project_loc}

    …told it not to build before launching, etc – and it works a treat! (it automatically issues a cd command after it launches if you do this). Regarding launching a terminal from the keyboard, because I’m running Quicksilver, I can hit cmd-space, t, e, r, return, and I’m there. (I ‘trained’ Quicksilver to launch iTerm instead of Apple’s Terminal when I type ‘ter’ – mentioned above)

    Also, if you’re new to the Mac and you’re not already running Growl, then my tip is to install that too (it’s a notification system – pretty slick too). It’s not used by Eclipse at all, but a lot of other apps use it and it can be very useful.

    Growl and Quicksilver are the two tools that really improved my Mac experience — there’s really no match for these two under Windows, as far as I know. (Although on Linux I also use Gnome Do, but it’s not as good as Quicksilver (yet) – and, sure, the Ubuntu notifications are a good effort, but no match for Growl (yet))

    Hope some of this proves useful?

    I think your blog is a great resource: thanks for all your hard work!

    Regards,
    /Jim

    • Thanks so much, Jim! This is great info. Double Command alone will save me from pulling out what little hair I have left. I use Home and End all the time to move within a line in Eclipse on Windows, and was getting pretty tired of losing my place on the Mac every time I hit those.

  3. Erron said

    I actually love my Mac. Though I’m forced to keep windows on a VM. I’m using virtual box. The primary advantage I see is that I don’t need a separate linux box for development and another box for my office productivity stuff. I think I’ll be able to reduce my use of the VM once our division allows us to use Entourage and IM for Mac (or I figure out how to hack into whatever exchange we are using). My biggest revelation was realizing that I needed to use a MS mouse instead of the Mac mouse since I’m a right-clicker. I think the performance of the Mac is has been fabulous as well. And I like just putting it to sleep, opening the cover, and back to work in less than 2 minutes.

  4. Charles said

    Interesting post. I’ve been mainly using a Mac for end-user stuff; I’m just now starting to use one as a developer. My pet peeves of Eclipse usage on a Mac are also keyboard-centric. I’m just listing them here in case anybody has seen an answer.

    – Dialogs don’t have shortcuts. So in the File Search dialog, I can’t press Alt-C to toggle case-sensitivity (or whatever the shortcut is; I don’t have my Windows machine any more).
    – Speaking of the File Search dialog, I’m finally getting used to pressing Command instead of Control (Command-V, Command-C, Command-J, etc.), so when I press Command-H to bring up the File Search dialog… it hides Eclipse (Command-H = hide). So on that one you have to press Ctrl-H.
    – The whole JDK thing is a little messy; my install didn’t have src.jar installed, so I had to get that as a separate download.
    – Also on the JDK, I need to work against JDK 1.5 for some of legacy projects; installing an older JDK is not as trivial as it is in Windows/Linux, where you can just unzip the thing and have Eclipse point to it.

    I’m hitting the Home/End key problem all the time (I just hit it typing this message 🙂 ). I think in the long run it’s better if I just learn the default Mac shortcuts, so while I looked at Double Commander thanks to this post, I’m going to just try to train myself.

    David, on accessing the menu with a key, did you know you can press Ctrl-F2? It’s much weaker than the Windows’ way, though as it just puts you on the Apple icon, and you have to arrow over to the menu you want. It’s frankly easier to just use the mouse to get to the menu, unfortunately.

    One other peeve is not Eclipse-specific — there’s not a key to maximize a window; you have to click on the little + sign on the title bar. And on some windows, maximizing doesn’t actually go full-screen, which I prefer. I haven’t figured out the pattern yet.

    All that said, I’m in general pretty happy with the Mac as a development machine.

    • Thanks, Charles. I’ve warmed up to the Mac considerably, though I still haven’t found a way to right click with the keyboard. By the way, in some apps like Chrome you can hold down Shift when you click the green maximize button to go full screen.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: