Recently I've purchased a new Mac and went through the typical, long and involved process of installing all the software I wanted on it. One application in particular, Netbeans, gave me some trouble. The installer simply refused to work. No matter, I figured. I'll just grab the universal version (it's written in Java after all). Sure enough it ran just fine.
One thing plagued me, however. Because the universal version doesn't have an actual .app file to put in your Applications directory you can't add it to the dock. While it's not a show-stopper it's clearly suboptimal.
I was certain there must be several ways I could wrap the netbeans startup shell script into an .app that I could add to my dock and maybe even set an icon for.
After some googling about I found several tutorials that did the job. Unfortunately they either involved some unnecessary steps or had information that was no longer accurate in Mac OS X 10.6. 2 Snow Leopard.
While I'm sure it may not be perfect either I decided to outline the steps I followed in the hopes that it will possibly help other Mac users trying to accomplish the same thing.
Wrapping your program in an AppleScript
The first thing we'll do is really all the meat. We'll put a three line AppleScript together that simply executes our target executable, netbeans in my case. Open up the AppleScript editor (located at /Applications/Utilities/AppleScript Editor.app in 10.6.2) and enter code similar to the following:
to run do shell script "/opt/netbeans/bin/netbeans" end run
Make sure to substitute the full path to the executable of your interest into line 2.
Now save the script into your /Applications folder but be careful to save it as an application, not as a script. I'll save mine as /Applications/run_netbeans.app.
Create an icon
Really we could stop now. You could copy the .app file to your dock and life would be merry. It would be ugly, however. We might as well give it a pretty icon while we've gone to all this trouble.
Keep in mind to follow these steps you'll need the Icon Composer which requires you to have the Apple developer tools installed.
It's quite simple, really. Just find or create a .png file of around 128x128-ish that you'd like for your application's icon.
Now fire up Icon Composer which will be located at /Developer/Applications/Utilities/Icon Composer.app. Drag your .png file into the square labeled 128 and ensure the contents that display in the square are correct. Click on the square so it's highlighted and copy it with command-c.
Using the Finder locate the .app file you created in your /Applications directory and hit command-i. Click on the icon at the top so it's highlighted then hit command-v which will paste your icon into the information window. Close out the window and, POW, you've changed the icon!
Feel free to close out Icon Composer. It's up to you weather you want to save the icon or not. I recommend at least keeping the original .png artwork.
Now you can drag your .app to the dock and enjoy!
Wed Apr 14 2010 16:04:00 GMT+0000 (UTC)