简体   繁体   English

如何正确设置JAVA_HOME环境变量?

[英]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: 包含以下目录:

  • bin 箱子
  • db D b
  • include 包括
  • jre JRE
  • lib LIB
  • man 男人

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.

相关问题 Bash shell脚本:如何设置JAVA_HOME环境变量 - Bash shell script: How to set JAVA_HOME environment variable 如何在Intelli J中设置JAVA_HOME环境变量 - How to set JAVA_HOME environment variable in Intelli J 如何修复 MAVEN 错误:未正确定义 JAVA_HOME 环境变量,运行此程序需要此环境变量 - How to Fix MAVEN ERROR: The JAVA_HOME environment variable is not defined correctly, this environment variable is needed to run this program 如果已经安装了JDK,请验证是否正确设置了JAVA_HOME环境变量 - If you already have installed the JDK, verify your JAVA_HOME environment variable is correctly set Maven JAVA_HOME 环境变量定义不正确,但它是 - Maven JAVA_HOME environment variable is not defined correctly, but it is 即使设置了系统 JAVA_HOME 环境变量,“echo %JAVA_HOME%”也会返回错误的路径 - "echo %JAVA_HOME%" returns wrong path even though System JAVA_HOME Environment variable set 如何修复maven错误未正确定义JAVA_HOME环境变量 - How to fix the maven error The JAVA_HOME environment variable is not defined correctly Maven 错误:JAVA_HOME 环境变量未设置 - Maven Error: JAVA_HOME Environment variable is not set 在Eclipse做appium测试时...如何设置JAVA_HOME环境变量让Android工具正常工作? - In Eclipse while doing appium testing ...How to set JAVA_HOME environment variable for Android Tools to work properly? maven如何知道JAVA_HOME在Ubuntu中设置为环境变量 - How does maven know JAVA_HOME set as an environment variable inUbuntu
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM