amitection
amitection

Reputation: 2933

Unable to locate JDK in Linux VM

I am trying to locate the JDK to setup jstatd but I am unable to locate it.

When I type java -version I get the following response

java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Then I tried locating it using the following 2 commands:

  1. which java

Response: /usr/bin/java

I tried to cd it but I get -bash: cd: /usr/bin/java: Not a directory

  1. Then I tried this whereis java
    Response: java: /usr/bin/java /usr/bin/X11/java /usr/share/java /usr/share/man/man1/java.1.gz

I again tried to cd it. But still not a directory. Where could it be installed?

Upvotes: 0

Views: 677

Answers (3)

Dmitry Ginzburg
Dmitry Ginzburg

Reputation: 7461

Are you sure java binary is not a symbolic link (maybe of a second level)? I'm pretty sure it is.

Just run ls -l on /usr/bin/java and discover the actual location.

For me, the final actual location is /usr/lib/jvm/java-7-openjdk-amd64/:

dmitry@dginzburg-win:~$ java -version
java version "1.7.0_101"
OpenJDK Runtime Environment (IcedTea 2.6.6) (7u101-2.6.6-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
dmitry@dginzburg-win:~$ which java
/usr/bin/java
dmitry@dginzburg-win:~$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Aug  14 16:23 /usr/bin/java -> /etc/alternatives/java
dmitry@dginzburg-win:~$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 46 Aug  14 16:23 /etc/alternatives/java -> /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
dmitry@dginzburg-win:~$ ls /usr/lib/jvm/java-7-openjdk-amd64/
bin  docs  jre  man

Upvotes: 3

Mustafa DOGRU
Mustafa DOGRU

Reputation: 4112

/usr/bin/java is not directory file. You can find the final location java file as below;

readlink -f $(which java); 

default location jdk is usualy in /usr/lib/jvm/

Eg; my config is :

user@host:$ ls -alrt /usr/bin/java
lrwxrwxrwx 1 root root 22 Dec 19  2014 /usr/bin/java -> /etc/alternatives/java

/usr/bin/java links to /etc/alternatives/java

user@host:$ ls -alrt /etc/alternatives/java
lrwxrwxrwx 1 root root 39 Jul  7  2015 /etc/alternatives/java -> /usr/lib/jvm/java-8-oracle/jre/bin/java

/etc/alternatives/java links to /usr/lib/jvm/java-8-oracle/jre/bin/java

user@host:$/usr/lib/jvm/java-8-oracle/jre/bin$ ls -arlt /usr/lib/jvm/java-8-oracle/jre/bin/java
-rwxr-xr-x 1 root root 7734 Mar 27  2016 /usr/lib/jvm/java-8-oracle/jre/bin/java

first letter - in -rwxr-xr-x means that this file type is file not directory.

Upvotes: 1

francesco foresti
francesco foresti

Reputation: 2043

Usually jdk's and jre's are located under /usr/lib/java or /usr/lib/jvm. To be sure, do an ls -la $(which java), it should be a symlink pointing to the real binary (You could have to repeat this operation, usually if there are alternatives this link could point to another link).

Upvotes: 1

Related Questions