Tuesday, August 17, 2010

Setting up .java files to automatically open with Eclipse on Mac OS X

With the 3.6 (aka, Helios) release of Eclipse, there is now support for opening files from the operating system command line or file browser directly into Eclipse. This has been a long-standing feature request (one of the oldest requests to ever have been implemented, in fact) and many people are happy to have it. Here is a quick tutorial on utilizing this feature under Mac OS X to associate .java files so that they open in Eclipse upon double-click from Finder. Although this demonstrates using .java files, you can do the same for any other file type; as long as your installation of Eclipse has an editor to handle that file type, it should work just fine.

  1. Just to re-iterate, you have to have Eclipse Helios (version 3.6 of the platform) in order to take advantage of this feature. If you don't already have it, go get it.
  2. In Finder, locate a .java file that you'd like to open in Eclipse; right-click (or Control+click if that's the way you roll) and select Get Info

  3. In the Info dialog, under the "Open with:" section, click the drop-down list and select Other...

  4. Here comes the only tricky part about this process.
    In the resulting Finder dialog to select an application, navigate to where Eclipse is installed. You'll see Eclipse.app listed but chances are, it's disabled; you can't select it. You just have to enable it using the Enable: drop-down list at the bottom of the window, as shown here:

    Once you do that, you'll be able to select Eclipse.app.

  5. Before clicking the Add button, decide if you want to select the "Always Open With" option (checkbox). Then click Add.
  6. Back in the "Info" dialog, you can use the Change All... button to associate all .java files with Eclipse. Even if you don't do it now, you an always come back to this dialog and do it later.
That's it. Now when you double-click on .java files they will be opened in the Eclipse installation that you selected. If an instance of Eclipse is already running, that instance will open the file. Otherwise, a new instance will be started.

Wednesday, July 28, 2010

Tip of the hat to Oracle

As most Eclipse community members probably already know, a recent change by Oracle in the JDK/JRE for Windows caused serious problems for Eclipse. But in a sign that Oracle really does understand the importance of Eclipse in the Java community, as well as a nice gesture of cooperation and consideration, they've rolled back the change that caused the problems and released new builds.
I admire Oracle's willingness to respond quickly to this issue, in spite of the fact that Eclipse code was admittedly relying on non-documented and non-API data. Ian Skerret also deserves credit for directly engaging people at Oracle to make this happen.

Hats off to cooperation!

Wednesday, April 21, 2010

Launching Multiple Instances of Eclipse on Mac OS X

Doug Schaefer recently griped that Eclipse on Mac "gets no love." I don't really agree in general, but I don't have the time to debate that in detail. I do, however, have the time to provide a simple work-around to one of his gripes, the inability to launch multiple copies of Eclipse simultaneously. As Doug mentions, this is inherent behavior for OS X applications, not an Eclipse-specific problem. But, there's a simple way to launch additional instances if you're willing to perform a few mouse clicks.
The basics:
  1. Right-click (Command+click) on the Eclipse Doc icon and choose Show in Finder.
  2. Right-click on Eclipse.app and choose Show Packages Contents.
  3. Navigate to Contents > MacOS directory.
  4. Double-click the eclipse executable there to launch Eclipse. Make sure to select a different workspace than is already open.
Here's a short screencast demonstration (click the image to play):