actually i im learning Linux (CentOs 7). I installed Java on root (usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java)
.
Now i have one question. if i type "java-version" i get
[mibe@localhost ~]$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
I thought that java only works if i set the JAVA_HOME
PATH in /etc/profile
. Why do i get a result for this call?
Because you installed java in /usr/lib
, this folder is in system environment. When you type java -version
, the system can find the command java
.
But if you install java in other folder not in system environment, you must set the JAVA_HOME
PATH in /etc/profile
to tell the system how to find the java
command, and there are other important reasons why to set the JAVA_HOME
not just for this.
https://stackoverflow.com/a/27996647/11559693