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/libphp5.so

Restart apache2

For a more in-depth howto, go here: http://foundationphp.com/tutorials/php_leopard.php

Advertisements
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

Image

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

Image

Sometimes, you get an error like this:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:118)
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:100)
at com.google.gdata.client.Service.<clinit>(Service.java:555)
at sample.contacts.ContactsExample.<init>(ContactsExample.java:133)
at sample.contacts.ContactsExample.main(ContactsExample.java:609)

It means you’re missing a class, specifically com.google.common.collect.Maps.

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;
done
Tagged , ,