Monthly Archives: November 2012

Enabling PHP on Mac OSX’s Apache2

If you read my last entry, you’ll know that Mac OSX comes with Apache2. It also comes with PHP, but Apache2 isn’t configured to enable it. Here’s the short and simple howto for enabling PHP on it.

Open the httpd.conf located at /private/etc/apache2/httpd.conf.

Uncomment the following line (by removing the #):

#LoadModule php5_module      libexec/apache2/

Restart apache2

For a more in-depth howto, go here:

Tagged , ,

Mac OSX comes with Apache2

To turn it on, you can either use the pretty menu windows or the command line.

The pretty menu windows way:

Go to System Preferences > Sharing, and click on Web Sharing


The command line way:

Open terminal and type “apachectl start” to start it, or “apachectl stop” to stop it.

Tagged ,

Finding a needle.class in (multiple) haystack.jar


Sometimes, you get an error like this:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at sample.contacts.ContactsExample.<init>(
at sample.contacts.ContactsExample.main(

It means you’re missing a class, specifically

Let’s say you download a package and get a million jars. How do you know if that class is in the jars and which one?

Try this linux script:

for i in *.jar; do jar -tvf "$i" | fgrep Maps; done

(note the quotes need to be regular quotes, and not the stylized ones WordPress imposes on me here)

If it’s found, you can print out all the classes in the jars into a text file and scan through it for the jar that contains your class

for i in *.jar;
  do echo "$i" >> myjarcontents.txt;
  jar -tvf "$i" >> myjarcontents.txt;
Tagged , ,