[英]How to correctly set the JAVA_HOME environment variable?
on a tutorial (related to a product) it is shown hot to set the JAVA_HOME environment variable on a Linux Ubuntu system, in this way: 在教程(与产品相关)上,显示热设置Linux Ubuntu系统上的JAVA_HOME环境变量是这样的:
echo "JAVA_HOME=\"/usr/lib/jvm/default-java\"" | sudo tee -a /etc/environment
I have some trivial doubts: 我有一些琐碎的疑问:
1) What exactly is the JAVA_HOME environment variable and for what is it used? 1) JAVA_HOME环境变量到底是什么?它的用途是什么?
From what I have understand it is something like a link to the JVM setted into the operating system that is used from the servlet container\\application server to know where the JVM is and so it can be used. 据我了解,它就像是设置到操作系统中的JVM的链接一样,可从servlet容器\\应用程序服务器使用该链接来了解JVM的位置,以便可以使用它。 Is this assertion true or am I missing something? 这个说法是对的还是我错过了什么? Exist some other purpose of this environment variable? 是否存在此环境变量的其他用途?
2) In the tutorial it is shown that the path of this environment variable is: 2)在本教程中,该环境变量的路径为:
/usr/lib/jvm/default-java
but into my system I have something different, infact into the /usr/lib/jvm/ path I have not the default-java directory but I have a path like this: 但是在我的系统中,我有一些不同之处,实际上是在/ usr / lib / jvm /路径中,我没有default-java目录,但是有这样的路径:
/usr/lib/jvm/java-8-oracle
that contains the following directories: 包含以下目录:
and some other files. 和其他一些文件。
What is the correct path to use for the settings of my JAVA_HOME environment variable? 用于设置JAVA_HOME环境变量的正确路径是什么?
3) What exactly does this section of the previous statment: 3)上一条陈述的这一部分到底做了什么:
sudo tee -a /etc/environment
Tnx TNX
1: You are correct 1:你是对的
2: It should point to the actual root folder of the jvm/jdk install, in this case /usr/lib/jvm/java-8-oracle
2:它应该指向jvm / jdk安装的实际根文件夹,在这种情况下为/usr/lib/jvm/java-8-oracle
3: tee is a command to output the input both to a file and the command line, that -a option appends it to the file. 3:tee是用于将输入输出到文件和命令行的命令,-a选项将其附加到文件。 So essentially it, as a super-user, appends the output of the previous command echo "JAVA_HOME=\\"/usr/lib/jvm/default-java\\""
to the file /etc/environment
but also outputs it to the command line. 因此,从本质上讲,作为超级用户,它会将前一个命令echo "JAVA_HOME=\\"/usr/lib/jvm/default-java\\""
的输出附加到文件/etc/environment
但也将其输出到命令线。 Output should be, for you, exactly: JAVA_HOME="/usr/lib/jvm/java-8-oracle"
对您来说,输出应该完全是: JAVA_HOME="/usr/lib/jvm/java-8-oracle"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.