Echo $ JAVA_HOME returns nothing

How to get java home directory?

Wherein

echo $JAVA_HOME

Nothing returns

enter image description here

+4
source share
3 answers

$JAVA_HOME is a global variable that you usually need to set yourself.

On some (most?) Platforms, installing Java will not set your variable JAVA_HOME.

The advantage here is that you can have multiple versions of Java coexisting on the same system.

Since you are working on a * nix system, you can do this in your own login scripts, such as ~/.bashrcor ~/.bash_profileetc.

+6
source

You need to set the variable $ JAVA_HOME

Maven , JDK.

, ​​JAVA:

$ whereis java
java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz

$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 46 Aug 25  2016 /etc/alternatives/java -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

:

$ ls -l /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
-rwxr-xr-x 1 root root 6464 Mar 14 18:28 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

, .

/etc/environment nano

$ sudo nano /etc/environment

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

PATH $ . /etc/environment

, $ echo $JAVA_HOME

:

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

, :

https://askubuntu.com/a/175519

fooobar.com/questions/61665/...

0

?

export JAVA_HOME=/usr/bin/java

:

JAVA_HOME Linux

-2

All Articles