1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Linux(今回はCentOS)でjavaの実体がどこにあるか調べる

Last updated at Posted at 2018-08-20

#結論
whichとlsを使い、リンクを追跡する。

# java -version
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)
# which java
/usr/bin/java
# ls -al /usr/bin/java
lrwxrwxrwx 1 root root 22  1月 24 13:51 2016 /usr/bin/java -> /etc/alternatives/java
# ls -al /etc/alternatives/java
lrwxrwxrwx 1 root root 34  1月 24 13:51 2016 /etc/alternatives/java -> /usr/java/jdk1.8.0_72/jre/bin/java

#背景
引き継いだサーバーのjavaが古いのではと疑われる事案があり、javaのある場所を確認したら、以下のようになっていた。

# ls -al /usr/java/
合計 20
drwxr-xr-x.  4 root root 4096  8月 20 09:43 2018 .
drwxr-xr-x. 14 root root 4096 12月 23 15:15 2015 ..
drwxr-xr-x   9 root root 4096  1月 24 14:00 2016 apache-tomcat-8.0.30
lrwxrwxrwx   1 root root   16  1月 24 13:51 2016 default -> /usr/java/latest
drwxr-xr-x   9 root root 4096  1月 24 13:51 2016 jdk1.8.0_72
lrwxrwxrwx   1 root root   21  1月 24 13:51 2016 latest -> /usr/java/jdk1.8.0_72
-rw-r--r--   1 root root 3405  1月 24 14:27 2016 velocity.log

tarを解凍したかったが、jdk1.8.0_72を直接参照しているのか、latestやdefaultを利用しているのかわからなくなり、確認した。

#余談
結局rpmをインストールした。

# ls -al /usr/java/
合計 24
drwxr-xr-x.  5 root root 4096  8月 20 09:56 2018 .
drwxr-xr-x. 14 root root 4096  7月  7 17:12 2018 ..
drwxr-xr-x   9 root root 4096  1月 24 14:00 2016 apache-tomcat-8.0.30
lrwxrwxrwx   1 root root   16  1月 24 13:51 2016 default -> /usr/java/latest
drwxr-xr-x   8 root root 4096  8月 20 09:55 2018 jdk1.8.0_181-amd64
drwxr-xr-x   9 root root 4096  1月 24 13:51 2016 jdk1.8.0_72
lrwxrwxrwx   1 root root   28  8月 20 09:56 2018 latest -> /usr/java/jdk1.8.0_181-amd64
-rw-r--r--   1 root root 3405  1月 24 14:27 2016 velocity.log
# which java
/usr/bin/java
# ls -al /usr/bin/java
lrwxrwxrwx 1 root root 22  8月 20 09:56 2018 /usr/bin/java -> /etc/alternatives/java
# ls -al /etc/alternatives/java
lrwxrwxrwx 1 root root 41  8月 20 09:56 2018 /etc/alternatives/java -> /usr/java/jdk1.8.0_181-amd64/jre/bin/java
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?