32cupo 32cupo - 1 year ago 141
Java Question

Nutch Error: JAVA_HOME is not set

I followed this tutorial http://saskia-vola.com/nutch-2-2-elasticsearch-1-x-hbase/ When I finally tried to run Nutch

sudo bin/nutch inject urls
I got this error

Error: JAVA_HOME is not set.

but when I echo JAVA_HOME it returns


and it is also in /etc/environment


and also I added line to end of file ~/.bashrc

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

but it still returns this error. How can I fix it?

Answer Source

You are running the command as root user, so the environment variables the application sees are the one's visible for root user not your user. Just check that the root has a JAVA_HOME environment variable set or run the program as your user, if possible.

You can try sudo -E bin/nutch inject urls

As the sudo manual says, -E, --preserve-env Indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the user does not have permission to preserve the environment.