I installed CDH in Pseudo distributed mode on Ubuntu 12.04.
Prior to it, I installed Java and exported my JAVA_HOME variables to /usr/lib/jvm/java-6-oracle and exported JAVA_HOME to path as well, for both root as well as other users (self, hdfs). and it was echoed correctly as well as showed up in env results.
Still my CDH installation complained of JAVA_HOME not found/set so I added JAVA_HOME to /etc/environment as per this and the entry Defaults env_keep+=JAVA_HOME in /etc/sudoers
All works fine, I can check services are running via Jps, but when I try to stop them as root it says,
service hadoop-hdfs-datanode stop
* Stopping Hadoop datanode:
Error: JAVA_HOME is not set and could not be found.
same goes for all other services.
I don't have hadoop-env.sh in my installation, the only one present is at /usr/lib/hadoop-0.20-mapreduce/example-confs/conf.secure/hadoop-env.sh which is an example I believe