Java 8 on OS X Yosemite

I downloaded a recent copy of IntelliJ, only to discover when I went to open it, OS  Yosemite indicated I had no version of Java installed, and that I’d need to install an old version. The “More Info…” button took me to this page:  http://support.apple.com/kb/DL1572

…which didn’t load.  (UPDATE: This fixed the load issue.) Similar detailed install directions also ended up at the same broken page.

So, I attempted to download Java 8 directly from Oracle and  install install it.  The install worked fine, but IntelliJ 14 still did not open.  Same error message.

Here’s how I solved it.  Hop into terminal and do this:

$ cd "/Applications/IntelliJ IDEA 14.app/Contents"
$ cp Info.plist Info.plist-orig
   
$ vi Info.plist    # ... any text editor will do

Find the line that says 1.6* and change it to 1.8*.  Save your file, and now go open IntelliJ as normal.

This causes IntelliJ 14 to use Java JDK 8, and all is right with the world.

List iTunes Apps by Purchaser

I finally developed a way to list all your iTune applications by Purchaser, and even better, I can do it from the command line.

Last year I was helping a friend who has pretty poor internet connectivity upgrade his iPad to the latest version of iOS. To do this, I connected his iPad to my system, performed a backup in iTunes, then synchronized to update the operating system. This had the side effect of beaming some of his applications to my iTunes, which in order to continue, he authenticated against. His iPad updated great, and he was on his way.

Things on my machine seemed okay for a while, that was until some of the apps he purchased that I didn’t have wanted to update. Not having his password, I wasn’t able to update them, but even worse, Apple wasn’t announcing which apps needed updating with his account so I could simply delete them as I wanted to.

Instead, for over a year, I was greeted in iTunes by a numerical indicator saying I needed up update my apps, but when I went to do it, I was up to date. Every once in a while I’d recognize an app that I didn’t purchase (in a haystack of nearly 1,000 iPhone apps) and delete it. Only then did the number drop, but later rise again when some other app needed updating.

What I needed to do was list out all the apps by Purchaser.

One of things that really annoys me about Apple is that stuff that is trivial to implement, like putting an optional Purchaser column in iTunes, they don’t do. The feature is half heartedly there, though. Press Command-I for Info, and you can see the purchaser for an item.

Only now you have to click and inspect your whole app list. And with the number of applications I own, this doesn’t scale well at all.

Searching the web reveals that others are in a similar bind, and that Apple seems to really care less about the few handful of users with this problem. Like much on the Apple Support Site, it’s unhelpfully silent.

Frustrated, I decided to solve this problem once and for all.  Open Terminal and cut’n’paste the following in:

for f in ~/Music/iTunes/iTunes\ Media/Mobile\ Applications/*.ipa; \
 do (echo "$f" ; unzip -p "$f" "iTunesMetadata.plist" | \
 plutil -p - | egrep -i "\\"(itemName|artistName|AppleID)\\"" ) | \
 perl -e 'while (<>) { if (m!^/!) { chop; $fqn=$_; } if (m/"(.+)" => (".+")/) { $e{lc($1)}=$2; } } print "\\"${fqn}\\",$e{\\"itemname\\"},$e{\\"artistname\\"},$e{\\"appleid\\"}\n";'; \
done

Turning Web Share Back On in Mountain Lion

Apple removed Web Share from Mountain Lion. Next they’ll be removing the Start button… oh, wait… that’s someone else. Here’s how to bring back Apache for those people who use their Mac to test and design websites.

I was rather surprised and disappointed to learn that Web Sharing was removed from Mountain Lion.

According to this post, it’s possible to bring back.

Per-user Web Sharing is gone from Preferences but can be easily re-enabled via Terminal.app. Copy the following snippet into /etc/apache2/users/USER.conf:


<Directory "/Users/USER/Sites/">
 Options Indexes MultiViews FollowSymlinks
 AllowOverride All
 Order allow,deny
 Allow from all
</Directory>

and restart Apache with sudo apachectl restart.

And PHP has been hidden as well, but again thanks to this article, it can come back as well.

Uncomment these lines by removing the leading pound sign in /etc/apache2/httpd.conf:

  • LoadModule rewrite_module libexec/apache2/mod_rewrite.so
  • LoadModule perl_module libexec/apache2/mod_perl.so
  • LoadModule php5_module libexec/apache2/libphp5.so

Groking Objective-C for Modern Day Programmers

Here’s what I think trips up solid programmers about the Objective-C language.

One of the nice things about Apple’s OS X for the Macintosh is that they include a free copy of Xcode, a very sweet graphical development environment allowing developers to make Cocoa applications using Objective-C.

The problem is, jumping straight into the Cocoa framework, even with tutorials, can be a daunting task if you’re not comfortable with Objective-C.

Yes, there are a number of books out there, but today I stumbled across, quite by accident, a fairly decent tutorial on Objective-C.

That got me thinking. In a world where we can easily pick up C++, C#, Java, Python, and Ruby… what is it about Objective-C that makes it hard to follow? Here’s what I think the major stumbling blocks are:

Notation Preconceptions Clouding C as the True Origin
In the classic examples, we think in terms of an object with methods and members, often using a dot-like syntax. As such, we tend to want to force fit Objective-C’s way of doing thing into some preconceived mold, and when the syntax doesn’t express that, things fall apart.

The Solution: Back off. Drop all the way back to C. Consider Objective-C nothing more than a well written pre-processor to useful object like extensions to the C programming language. Sure your implementation may very well be a compiler, but don’t think in those terms.

You’ve Got Classes Wrong
You’re used to thinking that a class is a data type. Don’t, think of it as a thing. In fact, Objective-C only needs to know a variable is a class, it doesn’t need to know which one or what it exposes. Classes are things whose primary role is to produce instances.

It’s Supposed To Feel Like Macro Magic
When you’re working on the guts of a class, you’ve got a lot of blocks that start with @class, @interface, @end, …. If it feels like something’s acting as a pre-processor and is converting that stuff into data structures and functions, it is. You’re not going to see pretty syntax that feels integrated into the language.

Hard Crunchy Outside, Soft Gooey Inside
A class exposes an interface, this is how the outside world sees and interacts with your class. Specifically, its your methods. And they’re all public. Get over it. Test. Only your members can be protected or private.

Remember, there are class-things and instance-things.

Declarations and Definitions
With C, there’s declarations that define the type and are often used for forward references; additionally, there are definitions where the memory is actually allocated and a value assigned.

Objective-C objects work similar. There’s an @interface / @end block that describes the object, its members, and its methods. And there’s an @implementation / @end block that actually contains the real code.

void * and id
A pointer in C, indicated by a *, points at a data type. If the pointer is given a void type, the compiler does no type checking. You know this. The id type holds a object, regardless what type it is.

Messages are not Methods
Any object can be sent any message. An object maps a message to a method. However, if there’s no mapping available, it can be handed to a general handler for the object — which can be clever and analyze the message.

Extended classes… and instances.
The mapping between message and method can be extended; you can think of it as subclassing. However, it’s possible to extend an instance. Meaning, a class might not respond to a message, while instance A does and instance B doesn’t.

Categories
Because messages are bound late to an object, and the magic is done with data structures rather than types, it’s possible to create a collection of methods and add them to a class, even pre-existing ones you don’t have source code for.

Protocols
A protocol neither exposes an interface, nor does it provide an implementation. It is simply a named collection of method signatures which is attached to classes. Because any message can be sent to any object instance (or class), it is helpful to be able to “ask” if certain messages will be honored; that’s what protocols are for.

It’s Not Named Parameters
The syntax of a method may look odd, primarily because parameters appear to have additional text:
-(void) rotate:(String *)shape clockwise:(float)degrees;

In many modern languages, a signature can be overloaded. However, go back to the trick “What Would Macros Do?” In this case, any text that appears in front of a parameter is not a named parameter, but part of the method name. The above method would be the logical equivalent of void rotate_clockwise( String *shape, float degrees ) in raw C.

Constructors / Destructors
In today’s languages, performing a new allocates memory and initialized the object. Objective-C splits these into two discrete operations; this allows you to allocate memory from different heaps, as well as deferring expensive initializations – no bogus empty constructors here.

Note, you are also responsible for calling the superclass’s init, before doing your own init. If you have a method to deallocate the object, when done you need to call the superclass’s deallocation routine.

C requires you to take on more responsibility and pay attention to order; Objective-C classes require the same amount of vigilance.

Extra Data Types
Objective-C provides some helper data types, but some of them are tied quite strongly to the messaging framework.

Installing Hadoop on OS X

Fix the “Unable to load realm info from SCDynamicStore” error on OS Lion when using Hadoop.

Using Homebrew to install Hadoop on Lion OS X 10.7, I ran into a snag.

Attempting to do:
$ hadoop namenode -format

Resulted in this error: Unable to load realm info from SCDynamicStore

The solution was in Brandon Werner’s blog on How to Set up Haddop on OS X Lion.

As he puts it, to fix this issue, simply add the following single line to your hadoop-env.sh file:

export HADOOP_OPTS="-Djava.security.krb5.realm=OX.AC.UK -Djava.security.krb5.kdc=kdc0.ox.ac.uk:kdc1.ox.ac.uk"

Other Tips

  • The use of $HADOOP_HOME is now deprecated.
  • Homebrew uses /usr/local/bin with symbolic links to its /usr/local/Celler, so Hadoop just works from the command line. No need to add it to your path.
  • The Hadoop config files reside in /usr/local/Cellar/hadoop/*/libexec/conf

Hidden Preference File

Check your ~/Libarary/Preferences directory, do you have this hidden file?

I’m not keen on applications that leave cruft or secret files on my system when there’s no need to do so.

I ran into a file on my laptop called ~/Library/Preferences/.bridge01.dat as well as .bridge3_01.dat — why a preference file is hidden, I don’t know.

Suspecting the file might be part of Adobe Bridge (it wasn’t), I copied it to the desktop, and looked at the file with less from the command console. It was clearly a binary preference file.

I renamed the file to bridge01.plist and started to open it with Xcode, although seeing BBEdit could open it, thought I’d give that a shot and was nightly impressed it detected the file type and presented it as a regular XML file.

Inside was slightly cryptic, but I recognized a sequence of text starting with ESC- and it looked like a serial number. Using Spotlight I was able to find another file that had a matching string, my purchase notes for Flux 3, by The Escapers.

Again, I’m not thrilled about hidden .dat files that ought to be public .plist files in my user’s preferences directory. But at least it was a mystery solved.

1Password Woes with Safari Extension (fix)

Safari 5.1 and 1Password 3.7.x not playing well? Getting a Database error? No such column? Overview key missing? Try this… it worked for me.

I’ve been having a very nasty problem using Safari 5.1 with the latest 1Password software, while other browsers like Chrome and Firefox work just fine. I get a red ‘Problem with database’ message that says “Database error: no such column: overview_key”. It looks something like this:

1Password 3.7.1 build 21089 / Safari 5.1  (7534.48.3) / OS X Lion 10.7

Here’s how I fixed it
Start Safari, go to Safari / Preferences… / Extensions, and remove the 1Password extension if you have it. Close Safari. Re-open Safari. Close Safari using the magical sequence Command-Option-Q. Re-open Safari. Open 1Password and use it’s preferences panel to reinstall the Safari extension. Go back to Safari, and if you’re as lucky as I was, it’ll work.

Installing node.JS on OS X 10.6

Having problems installing Node.JS because of missing OpenSSL problems? Here’s the solution to that problem for OS X.

When I went to go install a copy of node.JS on OS X 10.6, I ran into a little snag. Using git, or more specifically Tower, I was able to pull node right from github.

The steps to install node are as simple as:
$ ./configure
$ make
$ sudo make install

However, I was having problems at the ./configure stage. It was reporting:

Checking for openssl : not found

This resulted in a link error if one tries the make command.

Many of the web resources suggest installing libssl-dev, although being on OS X (and not Ubuntu) and having openssl already installed on my system, it turns out it was the detection mechanism and not a missing library that was the problem.

What I needed was the pkg-config package, because if it isn’t around, the configure step simply skips the check reporting openssl isn’t present.

To install it, I used Homebrew, a fantastic modern package manager that works exceptionally well with OS X.

All I needed to do was this step, and then the commands above.
$ brew install pkg-config

Node then worked like a champ.

Where’s my JDK?

Caught in the Java depreciation battle under OS 10.6 and can’t find where the Java Development Kit (JDK) now resides? Here’s a command that will tell you, allowing you to still use InteliJ and other IDEs on OS X.

There’s a lot going on with Java at the moment. Oracle acquires Sun, putting the language in squarely in hands that don’t inspire trust; the same thing happened with MySQL. Meanwhile, the Apache Software Foundation quits the Java SE/EE Executive Committee. And now Apple deprecates Java, and the reason doesn’t appear to be what you’d think.

Starting with OS X 10.6.3 update, developers got caught in the back lash. Things moved on the file system.

Upgrading IntelliJ, the IDE was asking me where my JDK was, as it certainly wasn’t where the software, or I, thought it should be.

You won’t find the location using /Applications/Utilities/Java Preferences.app.

But you can find it with some digging. Thanks to this developer release note from Apple, the following command from Terminal will spew out some XML.

$ /usr/libexec/java_home –xml

Find the dictionary section that has ‘x86_64’ in it, and you’ll find an entry that has a ‘JVMHomePath’ with something like:

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

You want to provide this full path to the IDE as where the JDK lives.

It’s worth pointing out that Apple recommends that if you install any 3rd party JVMs they should be installed in /Library/Java/JavaVirtualMachines or ~/Library/Java/JavaVirtualMachines.

Uninstalling Intego Software

I’d rather eat an orange then brush my teeth with peppermint toothpaste than deal with cleaning up my system after using Intego’s software. If anything can bring the Windows reboot experience, coupled with the leaving of software cruft, to the Mac platform, this software does it in my opinion. Here’s how I finally got rid of it all. I hope.

I recently purchased a Mac bundle with software and it included software from Intego, consisting of the Personal Antispam and Personal Backup applications. I installed them, and from that point forward it was an experience I’ve regretted and have been trying to undo. Only now do I think I’ve made some progress toward that goal.

Frankly, I didn’t get what the backup software did for me over many of the free solutions out there, and while the personal antispam look intriguing, it was intrusive as well and I decided to fall back to Apple’s spam filter included in Mail.

Even if a product doesn’t make it into my main line of recommendations, I often will keep it around in the event I suddenly have use for it. This, for example, is how TypeIt4Me eventually won me over.

Intego went out of their way to annoy me straight from the start. How so? Every time I went to install a package from them, they felt the need to do what appeared to be a gratuitous reboot. It was like being on frickin’ Windows. And they had to install their own update manager, which had to take a glory spot in the menu bar. And it had to do updates, which required even more reboots. I was done with them at that point, but don’t even get me started on the subscription scheme that rode on top of the atrocity.

So I wrote to them asking them how to uninstall their software. Here’s the reply I got:

Proper removal of the software package requires using the Installer package located in your software bundle or disc. If you have manually attempted to remove the software, you will need to first, reinstall the software again, then use the same Installer package to properly remove the applications.

If you need to, you can re-download the installer for Internet Security Barrier X6 using the link below:

http://www.integodownload.com/en/isbx6.html

Open the installer and select to uninstall all software. Restart your computer.

Great, another reboot. Lucky for me, I hadn’t tried to go off on my own path, plus I had the original installation utility. I tried it, and it appeared to work.

Notice I said appeared?

One week later, LittleSnitch pops up and reports my system is spontaneously trying to access Intego’s update service for the very set of applications that, for all evidence I could tell, I removed and forgot about. Apparently, no so.

LittleSnitch also reveals it’s TaskManagerDaemon who’s trying to deal with Intego’s NetUpdate buried in /Library/Intego. Thank you LittleSnitch, curse you Intego.

Intego leaves cruft. Running cruft. Seems this isn’t new of them, according to Apple archives.

Part of the Mac culture is being a good citizen. In my opinion, I feel they aren’t.

After uninstalling the software in exactly the manner they prescribe, enter this this command at your terminal:
sudo find / -name Intego -print

I suspect you’ll develop a similar facial tick as it starts returning output after scanning your disk.

Go grab a root shell, you’re gonna wanna also wipe out:

  • /Library/Intego and everything below it.
  • /Library/Application Support/Intego and everything below it.
  • /Library/Preferences/Intego and everything below it.
  • /Users/wls/Library/Application Support/Intego and everything below it.

Oh, and you’ll want to Reboot as well.

…it’s not like I had other applications up or was doing anything important.

After the reboot, you’ll notice tons of console messages from launchd. Now you need to do this.
$ launchctl
launchd% remove com.intego.task.manager.notifier
launchd% remove com.intego.netupdate.agent
launchd% exit

And, you’ll need to remove some .plist files:
$ sudo rm -v /Library/LaunchAgents/*intego*
$ sudo rm -v /Library/LaunchDaemons/*intego*

And preferences, frameworks, keychains, and widgets:
$ sudo rm -vrf /Library/PreferencePanes/NetUpdate.prefPane
$ sudo rm -vrf /Library/Frameworks/IntegoiCalFramework.framework/
$ sudo rm -v /Library/Keychains/Intego.keychain
$ sudo rm -vrf /Library/Widgets/Intego\ Status.wdgt/

Reboot again.

UPDATE (12-Dec-2010): I’ve been in contact with Intego Support, support@intego.com, and they were kind enough to provide this extra information:

If there is anything left on your computer, you can remove it manually.

Can you please go into the following areas on the computer and delete any traces of Intego or VirusBarrier:

/Macintosh HD/Library/Intego
/Macintosh HD/Library/LaunchDaemons
/Macintosh HD/Library/LaunchAgents
/Macintosh HD/Applications
/Macintosh HD/Library/Preferences
/Macintosh HD/Library/Logs
/Macintosh HD/Library/Receipts
/Macintosh HD/Library/Startupitems
/Macintosh HD/Library/Widgets

Home Folder:

~/Library/Application Support
~/Library/Preferences

They were right, there’s logs, too.
$ sudo rm -rf /Library/Logs/NetUpdate/

Review: Walt gives Intego software installation TWO thumbs down. The reasons are obvious.