Nutch错误:未设置JAVA_HOME

时间:2021-06-17 00:24:38

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

我按照本教程http://saskia-vola.com/nutch-2-2-elasticsearch-1-x-hbase/当我终于尝试运行Nutch sudo bin / nutch注入网址时出现此错误

Error: JAVA_HOME is not set.

but when I echo JAVA_HOME it returns

但当我回复JAVA_HOME时它会返回

/usr/lib/jvm/java-7-openjdk-amd64

and it is also in /etc/environment

它也在/ etc / environment中

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

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

我还在文件末尾〜/ .bashrc中添加了一行

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

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

但它仍然会返回此错误。我该如何解决?

3 个解决方案

#1


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.

您以root用户身份运行该命令,因此应用程序看到的环境变量对于root用户而不是您的用户是可见的。只需检查root是否设置了JAVA_HOME环境变量,或者如果可能,请以您的用户身份运行该程序。

You can try sudo -E bin/nutch inject urls

你可以试试sudo -E bin / nutch注入网址

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.

正如sudo手册所说,-E, - preserve-env向安全策略指示用户希望保留其现有的环境变量。如果用户没有保留环境的权限,安全策略可能会返回错误。

#2


make sure that the full JDK is there not only the JVM. you can also override this by export JAVA_HOME=YOUR_PREFERED_JDK_PATH in .bashrc file in you home directory.

确保完整的JDK不仅存在JVM。您也可以通过在主目录中的.bashrc文件中导出JAVA_HOME = YOUR_PREFERED_JDK_PATH来覆盖它。

#3


Probably you didn't set java path in /etc/environment. Try given command.

可能你没有在/ etc / environment中设置java路径。尝试给出命令。

sudo vi /etc/environment

and then set Java path

然后设置Java路径

JAVA_PATH=/give your java path here/

You can check java path by using $JAVA_HOME, and then use

您可以使用$ JAVA_HOME检查java路径,然后使用

sudo -E bin/nutch inject urls

#1


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.

您以root用户身份运行该命令,因此应用程序看到的环境变量对于root用户而不是您的用户是可见的。只需检查root是否设置了JAVA_HOME环境变量,或者如果可能,请以您的用户身份运行该程序。

You can try sudo -E bin/nutch inject urls

你可以试试sudo -E bin / nutch注入网址

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.

正如sudo手册所说,-E, - preserve-env向安全策略指示用户希望保留其现有的环境变量。如果用户没有保留环境的权限,安全策略可能会返回错误。

#2


make sure that the full JDK is there not only the JVM. you can also override this by export JAVA_HOME=YOUR_PREFERED_JDK_PATH in .bashrc file in you home directory.

确保完整的JDK不仅存在JVM。您也可以通过在主目录中的.bashrc文件中导出JAVA_HOME = YOUR_PREFERED_JDK_PATH来覆盖它。

#3


Probably you didn't set java path in /etc/environment. Try given command.

可能你没有在/ etc / environment中设置java路径。尝试给出命令。

sudo vi /etc/environment

and then set Java path

然后设置Java路径

JAVA_PATH=/give your java path here/

You can check java path by using $JAVA_HOME, and then use

您可以使用$ JAVA_HOME检查java路径,然后使用

sudo -E bin/nutch inject urls