Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I found where I defined JAVA_HOME

Here is my system info

wangbo@ubuntu:~$ uname -a
Linux ubuntu 4.4.0-72-generic #93-Ubuntu SMP Fri Mar 31 14:07:41 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

When I check java version

java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

but when I echo $JAVA_HOME

/usr/lib/jvm/java-9-oracle

It is unmatched , It seems that I defined $JAVA_HOME somewhere , but I can`t found it , Anyone can help me how can I found my $JAVA_HOME defined

Other useful info :

  1. I had install and uninstall jdk9 as first jdk before
  2. It is not in ~/.bashrc
  3. It is not in /etc/bash.bashrc
  4. It is not in ~/.profile

UPDATE

wangbo@ubuntu:~$ more /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
like image 973
Wangbo Avatar asked Apr 05 '17 11:04

Wangbo


1 Answers

1) JAVA_HOME is most probably defined in /etc/profile.d/jdk.sh and /etc/profile.d/jdk.csh These files are unfortunately not managed by the update-alternatives system.

2) Which executable you run should depend on the update-alternatives system, but if you have forced a particular version in your PATH it won’t.

Many java applications are actually invoked by scripts which choose their preferred jvm setting up a consistent environment, and shouldn’t be affected by your problem. It is best to have a consistent environment for free java invocations from the shell, however, and in most installations I know this is achieved manually...

Some java distributions don’t need JAVA_HOME at all. In other cases you need it. My advice is to define JAVA_HOME only when it turns out you need it. If it is the case, define it in a shell script and use that script to invoke the commands that you need that particular value for.

EDIT: /etc/profile.d/jdk.sh seems to be installed by oracle-java8-set-default.

# Uninstall the package (choose one)
sudo apt purge oracle-java8-set-default
sudo apt remove --purge oracle-java8-set-default

# Configure the desired Java binary
sudo update-alternatives --config java
sudo update-alternatives --config javac
like image 181
Dario Avatar answered Oct 22 '22 08:10

Dario