[英]Setting JAVA_HOME variable
I try to set JAVA_HOME
variable on an ubuntu server. 我尝试在Ubuntu服务器上设置
JAVA_HOME
变量。 I get the Java path with this command which java 我通过此命令获得了Java路径
/usr/bin/java
I set the result in /etc/environment 我将结果设置在/ etc / environment中
JAVA_HOME="/usr/bin/java"
When I try to run a mvn command I get this error 当我尝试运行mvn命令时,出现此错误
Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/bin/java/bin/java
You should not set JAVA_HOME
to /usr/bin/java
, because that's just a symbolic link to the java
executable, which points to where the real executable is. 您不应该将
JAVA_HOME
为/usr/bin/java
,因为这只是指向java
可执行文件的符号链接,指向实际可执行文件的位置。
JAVA_HOME
should point to the Java installation directory, and not to the java
executable (or a link to the executable). JAVA_HOME
应该指向Java安装目录,而不是java
可执行文件(或指向可执行文件的链接)。
Find out where your Java installation directory is and then set JAVA_HOME
to that directory (and not to the java
executable). 找出Java安装目录在哪里,然后将
JAVA_HOME
到该目录(而不是java
可执行文件)。 If you installed Java using Ubuntu's package management system, then the Java home directory is probably one of the subdirectories in /usr/lib/jvm
. 如果您使用Ubuntu的软件包管理系统安装Java,则Java主目录可能是
/usr/lib/jvm
中的子目录之一。
Per the Oracle site : 根据Oracle网站 :
export JAVA_HOME=jdk-install-location
export PATH=$JAVA_HOME/bin:$PATH
You can add these lines into your ~/.bash_profile
(or ~/.bashrc
), and then refresh using source ~/.bash_profile
您可以将这些行添加到
~/.bash_profile
(或~/.bashrc
)中,然后使用source ~/.bash_profile
刷新
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.