JAVA_HOME is not set - error

Hi - I am trying to install PIG for CDH3 as stated in the module-7. Followed the instructions provided but getting the JAVA_HOME is not set error. I wonder if you had similar error and if so what you did to resolve this. Additionally, should we be installing PIG for CDH3 or install PIG for Apache Hadoop. Please let me know. Thanks

5 Answer(s)


Login to your account and open .bash_profile file using following command
$ vi ~/.bash_profile

Set JAVA_HOME as follows using syntax export JAVA_HOME=
export JAVA_HOME=/usr/java/jdk1.6.0_07/bin/java

Set PATH as follows:
export PATH=$PATH:/usr/java/jdk1.6.0_07/bin

Save and close the file.

Just logout and login back to see new changes.
$ echo $JAVA_HOME
$ echo $PATH

Note : The java path above i used is just sample path. That must be replaced by the one as per your system.



Hi Ramana,

After making the changes what Amrit has suggested, you need NOT to logout.
You just has to execute following command from your terminal:
$source ~/.bash_profile
This will allow you to work with new java home without logging-out and logging-in.

Note: If you want to save and close a file [i.e. bash_profile, in this case, just press 'esc' then ':' then 'wq' and 'enter']

Please post, if you face any other issue.

vote-up, if it helps.
Happy Learning @ Dezyre!!


Thank you. For some reason, it seems this is not working. I must be doing something wrong. Here is what I have:

1. When I get to VMware, I am not getting login message

2. It seems my pwd is: cloudera@cloudera-vm:

3. I see java in /etc/alernatives/

4. But, java is not a directory

I will watch the last Sunday's recording again to ensure I am not missing something.

Please advise.

Thank you




Hi Ramana,

Most probably it should be under /usr/java/jdk...
Following command can help you checking this:
ls -l /usr/java/jdk*

This will result into some name "jdk1.6..."
This location will be your java home.
SO in ~/.bash_profile add:
export JAVA_HOME=/usr/java/jdk1..../bin/java
export PATH=$PATH:/usr/java/jdk1.6...../bin

And finally save the file and do a source ~/.bash_profile.
It should work then.
Please post, if it don't work.

Happy Learning @ Dezyre!!